2

As mentioned in SCTP receive message function returning zero, sctp_recvmsg() returns a length of 0 for a one-to-one SCTP connection (socket(PF_INET, SOCK_STREAM, IPPROTO_SCT)) when the other side closes the connection.

What happens / is supposed to happen for a standards compliant implementation when I send an empty string ("") with sctp_sendmsg() through such a connection?

  • (How) Does the receiving side tell apart whether I closed the connection or just sent an empty string/
  • Or is it illegal to send an empty string?

I haven't yet come across anything explaining this.

EDIT: I should mention that for standard recv() of SOCK_STREAM (e.g. for TCP), receiving a 0-length buffer happens when the peer has performed an orderly shutdown, thus apparently you're not allowed to send() an empty string in TCP. For a stream-only protocol like TCP this makes total sense, since 0-length data cannot have a meaning in a stream. But it could well have a meaning for a datagram as in the case of sctp_recvmsg(), so we can't really say "it's just like for TCP".

Community
  • 1
  • 1
nh2
  • 24,526
  • 11
  • 79
  • 128
  • 1
    In TCP an empty send is not detectable by the remote side. It is legal. – usr Aug 08 '15 at 21:10
  • At least the linux implementation will not let you send a zero sized message, it'll fail with EINVAL. (Though you can provide an empty message if you're shutting down/aborting a connection by the means of providing an ancillary SCTP_SNDRCV struct in the sendmsg() call that has SCTP_EOF or SCTP_ABORT flag set) – nos Aug 08 '15 at 21:24
  • @usr Correct. It is actually a useful way of testing the state of the connection. All the error checking happens but nothing goes on the wire or indeed into the socket send buffer. – user207421 Aug 08 '15 at 22:26

0 Answers0