Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

writing an array of bytes to a socket's output stream

807603Nov 3 2007 — edited Nov 5 2007
Hello, I would like to send a raw array of bytes using a socket's output stream. How do I accomplish this, and similarly, how do I retrieve the same array of bytes using a socket's input stream?
Something like this:
 
String IPaddress = "25.25.67.89";
Socket socket = new Socket(IPAddress, 2345);
byte[] bytes = new byte[4];
String[] split = IPaddress.split("\\.");
for(int i = 0; i < split.length; ++i){
   Integer value = new Integer(Integer.parseInt(split));
bytes[i] = value.byteValue();
}

// OutputStream os = socket.getOutputStream();
// How do I write the byte array to the outputstream?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 3 2007
Added on Nov 3 2007
3 comments
746 views