Link to home
Start Free TrialLog in
Avatar of Arumugam
Arumugam

asked on

Socket Communication Java to C

Server program written in C, which has got lot of structures.  I have to write the client program in JAVA.?  How can I do it.?  Any approach.?  Any examples.?
Avatar of Arumugam
Arumugam

ASKER

It is very very urgent.   Expecting answer as soon as possible.  Thanks in advance for the help.  
It shouldn't really matter what language the server's written in. As long
as you know what the data in the packet that it sends you and what it
expects, it should work perfectly fine.
ASKER CERTIFIED SOLUTION
Avatar of dys
dys

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I agree to you.. can you clear this point.
Server is expecting a structure in the form of "integer, unsigned short, string" at one time.  How to send this data to the server.?  So that server will take that and respond for me.  Hope you know that, unsigned short is 16-bit in C and 32-Bit in JAVA.  

Can you clear this point..  I agree to your answer.
Assume that server expecting a buffer which contains "integer, unsigned short, string".  How the client has to send that buffer in order to take care of unsigned short value.  (because unsigned short value is 16-Bit in C and 32-Bit in Java).
Another concern is the byte ordering, Little Endian or Big Endian. Mac machines use different from the PCs. You have to use byte sequences since they are universal. Thus, convert the data types to the expected amount of bytes in the order you think they should be and then the string should be zero terminated. I believe that the first two bytes (or four) of the structure are the size of the structure it self. So be carefull, because the server probably reads data in chunks of n (2 bytes), and then n bytes, then again n(2 bytes), and so on.