Jump to content
  • Advertisement
Sign in to follow this  
Vortez

WinSock Send/Recv problem...

This topic is 3717 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, im develloping a little library that manage networking task using winsock, and so far im doing well, but i ran into a little problem... Im trying to send a bitmap using non-bloking socket, single client/server apps. The problem is, if i send very little data, everything work fine, but if i try to send the entire image data(2Mo) i only got like 11k if i try to send all at once. Then if i try to send data by block of 4k, then im only able to recv maybe 5-6 chunk then, nothing... But if i debug the 2 apps then call send in the client app, then recv in the server, then everything seem to be working fine... Like if some windows read message are lost or something. Also, im using Send() and Recv() functions, should i use WSASend() and WSARecv instead? Thx for ur time.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Vortez
Hi, im develloping a little library that manage networking task using winsock, and so far im doing well, but i ran into a little problem...

Im trying to send a bitmap using non-bloking socket, single client/server apps.

The problem is, if i send very little data, everything work fine, but if i try to send the entire image data(2Mo) i only got like 11k if i try to send all at once.

Then if i try to send data by block of 4k, then im only able to recv maybe 5-6 chunk then, nothing... But if i debug the 2 apps then call send in the client app, then recv in the server, then everything seem to be working fine... Like if some windows read message are lost or something.

Also, im using Send() and Recv() functions, should i use WSASend() and WSARecv instead?

Thx for ur time.


There's a limit to how much you can send in a single packet. What you would want to do is do multiple sends until you've sent the entire image and not process it on the receiving side until you've received all the packets you expected to receive. To do this properly, you'll probably want to add a header for each packet with a sequence number so you can keep the packets in sequence and reassemble them properly on the receiving side.

Overall though, it's not surprising (it's actually expected) that you can't send a packet that large.

Share this post


Link to post
Share on other sites
Quote:
Original post by Vortez
Also, im using Send() and Recv() functions, should i use WSASend() and WSARecv instead?
Nah, send() and recv() (I assume you meant lower case first letters) are fine. Are you using TCP or UDP (SOCK_STREAM or SOCK_DGRAM)?

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!