-
September 17th, 2021, 01:08 AM
#1
Question about send() function.
I am using blocking sockets, so the function send() will block if the buffer gets too full. I will be using the Win API function send() to send data over the network. After the data is successfully sent, I want my program to immediately call closesocket(). Can I be assured that even if send() doesn't block, that the data has been successfully sent and that it is therefore safe to call closesocket()? Or, if it doesn't block, might it return too quickly, and therefore allow the closesocket() function to be called too soon, resulting in the socket closing before the data actually gets sent, and thus preventing the data from actually being sent?
-
September 17th, 2021, 02:14 AM
#2
Re: Question about send() function.
Didn't you read the documentation of send function?
There is a pretty clear description:
If no buffer space is available within the transport system to hold the data to be transmitted, send will block unless the socket has been placed in nonblocking mode. On nonblocking stream oriented sockets, the number of bytes written can be between 1 and the requested length, depending on buffer availability on both the client and server computers. The select, WSAAsyncSelect or WSAEventSelect functions can be used to determine when it is possible to send more data.
Victor Nijegorodov
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
|