Can anyone please help me on this query?
I have a server written in C and client in Java. I need to establish a tcp/ip connection between them.
Right now I am able to set a socket connection from my Java client program and created an input stream which is continuously reading data from the server.
I need to read based on the server's protocol. The server has a message header and few other information as a C program. Basically all information are being sent as packets.
I know the number of bytes for each data structure.
Now how can I read that from my java client in the same order? Do I need to wrap the io stream object to accept bytes?
All the data in the server is like raw data. Can anyone guide me how to receive data from server?
Joined: Oct 14, 2008
If you have an InputStream, then you can use that to read single or multiple bytes, can't you?
Joined: Jun 08, 2009
Yes I will be able to read multiple bytes. But how can I format my data while reading? Currently when I run my program it connects to the server and keep reading continuously.
But I need to have the data in the console in an ordered / formatted manner. Do I need to loop through the data and split it based on how the data is laid out in server protocol?