I wonder, why do I get not full response from my server ( Win ) to show its in client ( *nix )/
Herer are the codes:
Server ( Win ) : http://pastebin.com/CC1EHj0N<br />
Client ( *nix ) : http://pastebin.com/bFiLjMHh
The request from client ( “Hello from Gentoo!” ) my server gets well, but the response which sending to client isn’t rendering full at client side.
As you see, I used:
char response[]
And then sizing it with sizeof() in send method.
In the debugger, I’m getting result well, that must sending all sizedof bytes.
But in client , I’m getting not all string 🙁
Why?
There are (at least) 2 problems with your code:
In your client your buffer is smaller than the message sent by the server. Thus, it’s inherently impossible to receive the entire message in one go
You’re receiving only once. Nothing prevents
TCPfrom handing you the bytes one by one. TCP is stream-oriented, even if you’re providing enough space (which you’re not)To expand on the first point:
you send this message from the server
this is your receive buffer:
For starters, you could ensure that the client tries to
recvin a buffer that’s at least as large as the largest message sent by the server. But the true solution would be torecvin a loop.