tags:

views:

36

answers:

1

How can I know if the message has been sent by Tcp Socket in C# without client reply?

+1  A: 

If you send bytes using the Send method of a TCP Socket, TCP ensures that all bytes are delivered to the recipient. If the bytes cannot be delivered, the Send method will throw an exception.

Note, however, that a Socket may buffer some bytes before sending them, so even if TCP guarantees the delivery of the bytes, they might have not been sent yet when the Send method returns.

Also note that a program cannot determine if a TCP connection is broken if it only ever calls the Receive method. You have to send some data from time to time in order to check if the TCP connection is still working.

dtb
Thanks to sender side buffering this is not always true. Possible for a send to be buffered, and the the connection to fail.
Richard