sockets - 发送消息后断开与 TCP 套接字的连接是否保证交付?

标签 sockets go tcp

我找不到太多关于此的信息,但我有一个简单的代码序列,例如:

// 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/

相关文章:

sockets - 使用套接字时使用的是什么应用层协议(protocol)?

PHP 设置 MySQL 套接字位置

sockets - 连接到外部 SSL TCP 套接字到底是什么意思?

go - 从zip.NewWriter返回io.ReadCloser

networking - 为什么网络字节顺序定义为大端?

c - 如何使用 scanf 保持程序运行

c# - Windows 电话 8.1 IRC

php - 寻找一个不是用PHP编写的“下一代” CMS,或者是Wordpress的更好替代方案。

rest - 如何避免 Golang 服务器 (Gin Gonic) 在 INTERNAL_ERROR 上崩溃

android - 电报、whatsapp、viber TCP 连接