2

I'm writing a MFC app to implement a client/server scenario and using Win socket for that. I can send/receive a small message e.g. "hello". Also, I tried with buffer of size 1000. However, when I increase its size further, it just hangs. Doesn't even throw any error.

Any idea about what the problem could be? Is there any restriction on the maximum size of buffer I can send/receive in winsock? I'm a newbie in this and never used winsock before.

pree
  • 2,297
  • 6
  • 37
  • 55
  • 1
    The maximum size a TCP packet can have is 64K. Trying to send a packet with that size, will most likely cause your packet to get lost. A packet around 1000 bytes should not be a problem however. Please post some code. – Matt Apr 04 '13 at 21:19
  • I tried with 2000 bytes and it worked fine now. Didn't change the code for that. However, it fails for bigger data, say 9000 bytes. Also, when it hangs, I see "The thread 'Win32 Thread' (0x1bc0) has exited with code 0 (0x0)" on the output window of server app. – pree Apr 04 '13 at 23:06
  • Got it :) there was some minor bug in my code and also, I wasn't actually receiving the data from server end. I was waiting for all data to arrive instead. Now I can receive the data, in multiple runs though. – pree Apr 05 '13 at 00:25
  • 1
    Are you using TCP or raw sockets? TCP does not, at app level, transfer 'packets' and so I cannot understand some of the other comments. Application buffer sizes greater than 64k are not uncommon, and will work fine. – Martin James Apr 09 '13 at 08:23
  • I'm using TCP since winsock supports that. So when I was sending a big chunk of data (10000 bytes), I observed that I was able to retrieve only 9000 bytes of data at server app. And only after receiving it, I was able to retrieve the remaining 1000 bytes. Interestingly, I'm not able to reproduce the same case now. It gets me even the big chunk of data at a time which is probably what you are saying. – pree Apr 09 '13 at 16:55
  • 2
    The fact that you receive a part of the data, then the remaining part, is covered in my answer to [this question](http://stackoverflow.com/a/16016994/218597). It's basically the way TCP works. – icabod Apr 16 '13 at 09:40

1 Answers1

1

The following comment by icabod replies this question.

"The fact that you receive a part of the data, then the remaining part, is covered in my answer to this question. It's basically the way TCP works. – icabod"

Community
  • 1
  • 1
pree
  • 2,297
  • 6
  • 37
  • 55