1 .\" Copyright (c) 1983, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .Nd receive a message from an SCTP socket
44 .Fa "int s" "void *msg" "size_t len" "struct sockaddr * restrict from"
45 .Fa "socklen_t * restrict fromlen" "struct sctp_sndrcvinfo *sinfo" "int *flags"
51 is used to receive a message from another SCTP endpoint.
54 call is used by one-to-one (SOCK_STREAM) type sockets after a
57 call or after the application has performed a
59 followed by a successful
61 For a one-to-many (SOCK_SEQPACKET) type socket, an endpoint may call
63 after having implicitly started an association via one
64 of the send calls including
69 Or, an application may also receive a message after having
72 with a positive backlog to enable the reception of new associations.
74 The address of the sender is held in the
79 At the completion of a successful
83 will hold the address of the peer and
85 will hold the length of that address.
87 the address is bounded by the initial value of
89 which is used as an in/out variable.
91 The length of the message
93 to be received is bounded by
95 If the message is too long to fit in the users
96 receive buffer, then the
103 If the message is a complete message then
109 Locally detected errors are
110 indicated by a return value of -1 with
115 argument may also hold the value
116 .Dv MSG_NOTIFICATION .
118 occurs it indicates that the message received is
121 the peer endpoint, but instead is a notification from the
125 Note that no notifications are ever
126 given unless the user subscribes to such notifications using
131 If no messages are available at the socket then
133 normally blocks on the reception of a message or NOTIFICATION, unless the
134 socket has been placed in non-blocking I/O mode.
137 system call may be used to determine when it is possible to
142 argument is defined as follows.
144 struct sctp_sndrcvinfo {
145 uint16_t sinfo_stream; /* Stream arriving on */
146 uint16_t sinfo_ssn; /* Stream Sequence Number */
147 uint16_t sinfo_flags; /* Flags on the incoming message */
148 uint32_t sinfo_ppid; /* The ppid field */
149 uint32_t sinfo_context; /* context field */
150 uint32_t sinfo_timetolive; /* not used by sctp_recvmsg */
151 uint32_t sinfo_tsn; /* The transport sequence number */
152 uint32_t sinfo_cumtsn; /* The cumulative acknowledgment point */
153 sctp_assoc_t sinfo_assoc_id; /* The association id of the peer */
158 .Fa sinfo->sinfo_ppid
159 field is an opaque 32 bit value that is passed transparently
160 through the stack from the peer endpoint.
161 Note that the stack passes this value without regard to byte
165 .Fa sinfo->sinfo_flags
166 field may include the following:
168 #define SCTP_UNORDERED 0x0400 /* Message is un-ordered */
173 flag is used to specify that the message arrived with no
174 specific order and was delivered to the peer application
176 When this flag is absent the message
177 was delivered in order within the stream it was received.
180 .Fa sinfo->sinfo_stream
181 field is the SCTP stream that the message was received on.
182 Streams in SCTP are reliable (or partially reliable) flows of ordered
186 .Fa sinfo->sinfo_context
187 field is used only if the local application set an association level
191 Optionally a user process can use this value to index some application
192 specific data structure for all data coming from a specific
197 field will hold the stream sequence number assigned
198 by the peer endpoint if the message is
201 For unordered messages this field holds an undefined value.
205 field holds a transport sequence number (TSN) that was assigned
206 to this message by the peer endpoint.
207 For messages that fit in or less
208 than the path MTU this will be the only TSN assigned.
209 Note that for messages that span multiple TSNs this
210 value will be one of the TSNs that was used on the
214 .Fa sinfo->sinfo_cumtsn
215 field holds the current cumulative acknowledgment point of
216 the transport association.
217 Note that this may be larger
218 or smaller than the TSN assigned to the message itself.
221 .Fa sinfo->sinfo_assoc_id
222 is the unique association identification that was assigned
224 For one-to-many (SOCK_SEQPACKET) type
225 sockets this value can be used to send data to the peer without
226 the use of an address field.
227 It is also quite useful in
228 setting various socket options on the specific association
233 .Fa sinfo->info_timetolive
237 The call returns the number of bytes received, or -1
238 if an error occurred.
246 An invalid descriptor was specified.
252 An invalid user space address was specified for an argument.
254 The socket requires that message be sent atomically,
255 and the size of the message to be sent made this impossible.
257 The socket is marked non-blocking and the requested operation
260 The system was unable to allocate an internal buffer.
261 The operation may succeed when buffers become available.
263 The output queue for a network interface was full.
264 This generally indicates that the interface has stopped sending,
265 but may be caused by transient congestion.
266 .It Bq Er EHOSTUNREACH
267 The remote host was unreachable.
269 On a one-to-one style socket no association exists.
271 An abort was received by the stack while the user was
272 attempting to send data to the peer.
274 On a one to many style socket no address is specified
275 so that the association cannot be located or the
276 SCTP_ABORT flag was specified on a non-existing association.
278 The socket is unable to send anymore data
279 .Dv ( SBS_CANTSENDMORE
280 has been set on the socket).
281 This typically means that the socket
282 is not connected and is a one-to-one style socket.