WSAAsyncSelect crashes
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: WSAAsyncSelect crashes

  1. #1
    Join Date
    Sep 2010
    Posts
    33

    WSAAsyncSelect crashes

    Hi,
    my server and client use WSAAsyncSelect to handle the sockets connection.
    when my client connects to the server, the server sends an image of about 195,000 Bytes using 1 send() call.
    for some reason, the client only rarely gets the entire image. usually it stops in the middle. I made a button that calls recv() on press. when i see the client has stopped getting packets, i press that button and it receives the remaining packets (about 40,000 Bytes).
    if i try using my window handler after the client gets stuck, it crashes, so my conclusion is that for some reason the window handler being lost, and therefore WSAAsyncSelect stops sending messages about recv() calls.

    Any idea why will it crash?

  2. #2
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: WSAAsyncSelect crashes

    The client needs to call recv in a loop cause the TCP subsystem is not able to serve such a huge buffer with one call. You will get the number of bytes read with each call and have to add the number of already received bytes to the buffer address passed with recv. Unfortunately, there is no safe way to find out when the read is complete beside the server has put the total size of bytes to send at the begin of the buffer where you can read it with the first call to recv.

    The crashing probably is because the buffer provided by the client is too small.

  3. #3
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: WSAAsyncSelect crashes

    Sorry, I missed that you were using the WSA functions and not the native socket functions. But the principal problem should be the same.

  4. #4
    Join Date
    Sep 2010
    Posts
    33

    Re: WSAAsyncSelect crashes

    i pretty much changed the entire sending system to be more efficient and it works now
    thanks alot!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center