How can I know if the message has been sent by Tcp Socket in C# without client reply? [closed]
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, 开发者_运维百科and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this questionHow can I know if the message has been sent by Tcp Socket in C# without client reply?
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.
精彩评论