-
November 17th, 2005, 10:43 PM
#1
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.
-
November 20th, 2005, 04:47 PM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|