UDS 套接字 returns 上的 send() 而不发送整个数据。为什么?

send() on a UDS socket returns without sending the entire data. Why?

我正在开发嵌入式设备 运行 Linux。在我的应用程序中,服务器线程打开 UDS 套接字并等待连接。当客户端(不同的 application/process)连接时,它会处理请求并发送请求的数据。

请求的数据通常大于52KB。然而,send() 调用在仅发送 32064 字节后 returns。这种行为是间歇性出现的;通常整个 52KB 或更多都毫无问题地发送到客户端进程。

有人可以建议在传输过程中将 send() 发送到 return 的可能原因是什么吗?

我没有客户端代码,只有服务器代码,但我不能在此处 post。据我所知,我没有看到服务器代码曾经关闭过所述套接字。它仅在整个应用程序关闭时关闭。

有没有一种方法可以在客户端或服务器不显式关闭套接字连接的情况下结束套接字连接?因为我没有客户端 clode,所以我正在寻找服务器代码做一些愚蠢的事情的可能性。

感谢对此的任何意见。

谢谢!

成功发送()return发送的字节数,这不能保证您的所有数据都已写入,您需要用剩余数据再次调用它,此行为取决于内部缓冲区大小。 read() 函数的行为相同。

"The only difference between send() and write(2) is the presence of flags. With a zero flags argument, send() is equivalent to write(2)." 来源:man 2 send

"The number of bytes written may be less than count if, for example, there is insufficient space on the underlying physical medium, or the RLIMIT_FSIZE resource limit is encountered (see setrlimit(2)), or the call was interrupted by a signal handler after having written less than count bytes. (See also pipe(7).)" 来源:man 2 write