Jump to content
  • Advertisement
Sign in to follow this  
Unconquerable

recv() question.

This topic is 4486 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
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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!