CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2005
    Posts
    18

    Unhappy serious problem in send()

    I am implementing multi-server-client program.

    I use the select function to detect sockfd which is available to read and write so as to solve the blocking problem when send/recv.

    Now, I meeting a interesting problem.

    Although the select() indicate a sockfd ( Server B) is available to be written (there is send buffer left in the kernel), when I call send() to send a large packets (which the size is larger than the remaining kernel buffer size) to Server B, it may still be blocked if Server B is busy and not calling recv().

    Then i use setsockopt to set send timeout. But I found that since the large packets is divided into various packets and already sent out a few packets. After timeout it return error, but it cannot discard those packets already sent out. Server B then will receive incomplete msg.

    How can I ensure check the current remaining kernel buffer size before I start sending out the first packets ?
    Last edited by Damon123; November 17th, 2005 at 11:29 PM.

  2. #2
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: serious problem in send()

    Don't send a single large packet. Send multiple smaller ones untile send() returns WSAEWOULDBLOCK (use non-blocking sockets)

    Mike

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured