import java.net.*;
import java.util.*;
import java.io.*;
import static BH.Bytes_Hex.*;
public class byteServer {
public static void main(String args[]) {
try {
ServerSocket s_socket = new ServerSocket(5000);
Socket sock = s_socket.accept();
DataInputStream dataIn = new DataInputStream(sock.getInputStream());
int length = dataIn .readInt(); // read length of incoming message
byte[] the_bytes = new byte[length];
dataIn.readFully(the_bytes, 0, length); // read the message
System.out.println(ByteArray2HexString(the_bytes));
System.out.println("the_bytes length Received= "+length);
String the_string = new String(the_bytes,"UTF8");
System.out.println(the_string);
} catch (Exception e) {
return;
}
}
}