我目前正在Tru64上运行一个旧系统,它涉及使用sendto()函数的大量UDP套接字。套接字用于我们的代码中,以便将消息发送到各种进程或从各种进程发送消息,然后最终发送到远程连接的胖客户端应用程序。有时,胖客户端的套接字卡住了,这可能会导致一些消息被建立起来。我的问题是如何确定当前的缓冲区大小,以及如何确定最大的消息缓冲区。下面的代码给出了我如何设置端口并使用sendto函数的片段。Sendto上Tru64正在返回ENOBUF
/* need to adjust the maximum size we can send on this */
/* as it needs to be able to cope with the biggest */
/* messages we send */
lenlen = sizeof(len) ;
/* allow double for when the system is under load */
int lenlen, len ;
lenlen = sizeof(len) ;
len = 2 * 32000;
msg_socket = socket(AF_UNIX,SOCK_DGRAM, 0);
result = setsockopt(msg_socket, SOL_SOCKET, SO_SNDBUF, (char *)&len, lenlen) ;
result = sendto(msg_socket,
(char *)message,
(int)message_len,
flags,
dest_addr,
addrlen);
注意。我们已经将这个应用程序移植到Linux上,并且这个问题似乎并没有出现在那里。
任何帮助将不胜感激。
Regards