SCTP receive message function returning zero

自古美人都是妖i 提交于 2020-01-03 03:44:06

问题


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?

Thanks in Advance.

Regards, Sujay


回答1:


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.

Quoting:

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?

The sctp_recvmsg() will return 0 on termination only on 1-to-1 sockets. However, the above notifications will work on both styles.



来源:https://stackoverflow.com/questions/21595181/sctp-receive-message-function-returning-zero

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!