Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to send a byte array in socket java

Socket socket = ...
DataInputStream dIn = new DataInputStream(socket.getInputStream());

int length = dIn.readInt();                    // read length of incoming message
if(length>0) {
    byte[] message = new byte[length];
    dIn.readFully(message, 0, message.length); // read the message
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #send #byte #array #socket #java
ADD COMMENT
Topic
Name
6+6 =