Callbacks using asynchronous sockets

My assignment is pretty simple and concerns asynchronous sockets using the TCP protocol.

When I send some data using the "BeginSend" method, when will the callback be called?

Will it be called when data is simply being sent to the network, or when we guarantee that the data has reached its destination (as with the TCP specification)?

Thank you for your responses.

kite.

ps: I'm sorry if my english is a little bad ^^.

+2


source to share


2 answers


From MSDN:

"When your application calls BeginSend, the system will use a separate thread to execute the specified callback method and will block EndSend until the Socket sends the number of bytes requested or throws an exception."



"Successful completion of the submission does not mean that the data was successfully delivered. If the transport system does not have free space to store the data to be sent, the submission will block unless the socket has been placed in non-blocking mode."

http://msdn.microsoft.com/en-us/library/38dxf7kt.aspx

+3


source


When the callback is called, you can be sure that the data has been removed from the output buffer (the asynchronous operation uses a separate thread to ensure that your calling thread is not blocked if there is no room in the transmit buffer and must wait to send the date). and that he will reach the goal, but not reach it.

However, due to the nature of the TCP protocol, you can be sure (well, I think almost certainly) that it will eventually reach its destination.



However, for synchronization purposes, you shouldn't count the callback time as the same as the time the data reaches the other side.

+3


source







All Articles