• Advertisement
Sign in to follow this  

recv() question.

This topic is 4249 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I'm playing around with Winsock, and i have a basic server and a basic client. When the client connects to the server, you can type something in to the server to send to the client. That works fine, but on the client, after it prints what the server sent, it prints a little line of jibberish characters. To see what i mean: Thanks.

Share this post


Link to post
Share on other sites
Advertisement
You probably aren't sending and/or receiving the terminating null for the string.

Share this post


Link to post
Share on other sites
Well, how are you doing your sends and receives now?

Share this post


Link to post
Share on other sites
When you send, send the string plus the character '0' at the end.

A string in C is an array of characters ended by this character.

Share this post


Link to post
Share on other sites
strlen() doesn't include the terminating null when counting the characters in the string. Solution: add one to result of strlen() to account for the terminating null.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
strlen() doesn't include the terminating null when counting the characters in the string. Solution: add one to result of strlen() to account for the terminating null.


That worked, thank you. =D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement