Skip to main content
gamedev.net
🔒 Locked

[java] Java client and C socket Problems

Started by foo_mark 4 replies 550+ views
Original Post
foo_mark
foo_mark
I''ve sent the first string from my server into the buffer, and my Java client receives the message, but the problems starts when the client tries to receive the second message. Have anybody had problems receiving the second message from a server made in C? Because my server is sending a string message to my client in the buffer, but for some reason, the Java client is still waiting for a response. Can anybody clarify on this?
NuffSaid
NuffSaid
What is the string being sent, and what is the code that you''re using to read the string in the client?
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
HenryApe
HenryApe
When this happens with Java servers the problem is usually that the message is buffered at the server so one has to call the flush method on the output stream to make it send the message, maybe something similar is happening on your C server?

Many TCP implementations also supports a packaging algorithm that waits to send data until it has accumulated a certain amount of it. Try turning off Nagle''s algorithm on your socket, if that can be done from C.
foo_mark
foo_mark
And how would you do that? (What function call should I use in use in C to flush the buffers)
foo_mark
foo_mark
I wonder, could it be that the client is waiting for a carrige line return feed (i.e. ''\n''), since its using a readLine() in the Java client.
NullSeraph
NullSeraph
Yeah that could definitely be a problem. Try using a ''\n'' at the end of the string or a ''\r\n''. Hope one of those works for you.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.