I\'m writing a java socket program to read data from server, I\'ve no control to server, below is protocol agreed,
Use a DataOutputStream around a BufferedOutputStream around the `Socket.getOutputStream(). Then you can use:
writeShort() for the magic numberwriteShort() for the length wordwrite() for the payload.Similarly you can use DataInputStream and the corresponding readXXX() methods to read the response.
NB You are writing to a socket here, not a server socket.