View Single Post
Old Jul 2nd, 2005, 9:26 PM   #4
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 850
Rep Power: 4 The Dark is on a distinguished road
In this line in the server
		net=recv(client,rdata,strlen(rdata),0);
Don't use strlen, use sizeof - you want to be able to fill out your entire buffer, not just up to the first zero byte of the random data that is in there.

In this line in the client
		net=send(server,data,strlen(data),0);
You haven't put anything in data yet, so it contains random garbage, which might be a null in the first byte. This would mean you are attempting to send nothing, which probably would cause an error.

You need to either send the zero byte from the client to the server, to indicate end of string, or use the received length to add a zero byte to the end of the characters you are putting in rdata on the server, otherwise your string is unterminated.
The Dark is offline   Reply With Quote