SCTP接收消息功能返回零 [英] SCTP receive message function returning zero
问题描述
我编写的客户端程序使用SCTP套接字进行通信.我正在使用sctp_recvmsg从套接字读取特定用户可用的数据.我注意到,有时sctp_recvmsg返回0值而不是读取的字节数或-1表示错误.我检查了我的代码,读取数据的套接字没有关闭.有人可以阐明如何看待这种行为吗?
The client program i have written uses SCTP sockets for communication. I am using sctp_recvmsg to read the data available for a particular user from socket. I have noticed that at times sctp_recvmsg returns 0 value instead of number of bytes read or -1 indicating an error. I have checked my code and the socket from which data is being read is not closed. Can someone throw light on how can such a behavior be seen?
预先感谢.
关于, Sujay
推荐答案
根据此lksctp线程,如果您处于一对一的SCP连接(
According to this lksctp thread, sctp_recvmsg()
returns 0 if the other side closed the connection when you are in a 1-to-1 SCP connection (see here for an explanation of one-to-one and one-to-many connections) - that is, when you create the socket with SOCK_STREAM
instead of SOCK_SEQPACKET
.
报价:
未记录来自sctp_sendmsg和sctp_recvmsg的返回值,但 我想sctp_sendmsg将返回-1并将errno设置为ECONNRESET 和sendmsg一样.但是,sctp_recvnmsg呢?清楚的 如果关闭半连接,则recvmsg应该返回0,但是没有 SCTP中的半连接.该函数的行为如何?
Return values from sctp_sendmsg and sctp_recvmsg are not documented, but I would suppose sctp_sendmsg would return -1 and set errno to ECONNRESET same way as sendmsg does. However, what about sctp_recvnmsg? Plain recvmsg should return 0 if half-connection is closed, but there are no half-connections in SCTP. How does the function behave exactly?
sctp_recvmsg()在终止时仅在1对1套接字上将返回0. 但是,以上通知在两种样式上均适用.
The sctp_recvmsg() will return 0 on termination only on 1-to-1 sockets. However, the above notifications will work on both styles.
这篇关于SCTP接收消息功能返回零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!