Subject: message boundaries of SOCK_STREAM + SOCK_SEQPACKET

From: Oliver Kowalke <[email-masked]>
Date: Mon, 22 Jan 2007 17:49:42 +0100

Hello,

SCTP preservs message boundaries.
If the sender sends the two-byte message length field x and the x ytes large 
data message in a scattered write with sendmsg? What happens if the receiver 
reads 2 bytes and then x bytes form the SCTP socket?
Does SCTP also throw away the content of the message after reading two bytes 
like UDP implementations on most platforms?
For SOCK_SEQPACKET I would assume yes - but what happens for SOCK_STREAM SCTP 
sockets?

regards,
Oliver

---

From: Randall Stewart <[email-masked]>
Date: Tue, 23 Jan 2007 09:32:44 -0500

> For SOCK_SEQPACKET I would assume yes - but what happens for SOCK_STREAM SCTP 
Oliver:
Not sure I understand so I will illustrate two things below..

Case 1 user does:

write(..., 2 bytes)
write( iov, scattered-msg)

Or

Case 2 user does

write( iov, msg)

where
iov[0] - 2 bytes
iov[1] - msg part 1
iov[2] - msg part 2

So in case 1 you would read a 2 byte message followed by a
N byte message where N is the number of bytes written in
the second write

In case 2, if you only read 2 bytes.. SCTP would
then HOLD the rest of the message for the next
read .. if you were doing recvmsg() you would see
in the flags that MSG_EOR would NOT be set in this
2 byte message.. telling you the next read will
return MORE of the same message.

The next read could then be issued and would
return the rest of the message with MSG_EOR
set (assuming the read buffer was big enough
to hold the rest of the message)...

R

-- 
Randall Stewart
NSSTG - Cisco Systems Inc.
803-345-0369 <or> 803-317-4952 (cell)