我找不到太多关于此的信息,但我有一个简单的代码序列,例如:
// does it wait on Write() until successful handshake or attempt failure
// or just continue on straight away?
net.conn.Write(buffer[1:60])
conn.Close()
这是否保证在调用 Close
之前交付给客户端/服务器?或者是否会在消息发送后调用 Close,如果握手太慢而无法及时完成,则可能会在握手期间关闭连接?
最佳答案
Does this guarantee delivery to client/server before
Close
is called?
没有。
Or will
Close
be called after the message sent
写入和关闭都在排队等待异步执行。
and potentially close the connection during the handshakes if they were too slow to complete in time?
Close
将排队关闭连接。如果关闭握手时间过长,连接将被重置。
关于sockets - 发送消息后断开与 TCP 套接字的连接是否保证交付?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47966008/