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
36 .Nd send a message from an SCTP socket
45 .Fa "int sd" "const void *msg" "size_t len"
46 .Fa "const struct sctp_sndrcvinfo *sinfo" "int flags"
50 .Fa "int sd" "const void *msg" "size_t len" "struct sockaddr *addrs"
51 .Fa "int addrcnt" "const struct sctp_sndrcvinfo *sinfo" "int flags"
57 is used to transmit a message to another SCTP endpoint.
59 may be used to send data to an existing association for both
60 one-to-many (SOCK_SEQPACKET) and one-to-one (SOCK_STREAM) socket types.
61 The length of the message
65 If the message is too long to pass atomically through the
71 the message is not transmitted.
73 No indication of failure to deliver is implicit in a
75 Locally detected errors are indicated by a return value of -1.
77 If no space is available at the socket to hold
78 the message to be transmitted, then
80 normally blocks, unless the socket has been placed in
81 non-blocking I/O mode.
84 system call may be used to determine when it is possible to
85 send more data on one-to-one type (SOCK_STREAM) sockets.
89 structure is used to control various SCTP features
90 and has the following format:
92 struct sctp_sndrcvinfo {
93 uint16_t sinfo_stream; /* Stream sending to */
94 uint16_t sinfo_ssn; /* valid for recv only */
95 uint16_t sinfo_flags; /* flags to control sending */
96 uint32_t sinfo_ppid; /* ppid field */
97 uint32_t sinfo_context; /* context field */
98 uint32_t sinfo_timetolive; /* timetolive for PR-SCTP */
99 uint32_t sinfo_tsn; /* valid for recv only */
100 uint32_t sinfo_cumtsn; /* valid for recv only */
101 sctp_assoc_t sinfo_assoc_id; /* The association id */
106 .Fa sinfo->sinfo_ppid
107 argument is an opaque 32 bit value that is passed transparently
108 through the stack to the peer endpoint. It will be available on
109 reception of a message (see
110 .Xr sctp_recvmsg 3 ) .
111 Note that the stack passes this value without regard to byte
115 .Fa sinfo->sinfo_flags
116 argument may include one or more of the following:
118 #define SCTP_EOF 0x0100 /* Start a shutdown procedures */
119 #define SCTP_ABORT 0x0200 /* Send an ABORT to peer */
120 #define SCTP_UNORDERED 0x0400 /* Message is un-ordered */
121 #define SCTP_ADDR_OVER 0x0800 /* Override the primary-address */
122 #define SCTP_SENDALL 0x1000 /* Send this on all associations */
123 /* for the endpoint */
124 /* The lower byte is an enumeration of PR-SCTP policies */
125 #define SCTP_PR_SCTP_TTL 0x0001 /* Time based PR-SCTP */
126 #define SCTP_PR_SCTP_BUF 0x0002 /* Buffer based PR-SCTP */
127 #define SCTP_PR_SCTP_RTX 0x0003 /* Number of retransmissions based PR-SCTP */
132 is used to instruct the SCTP stack to queue this message
133 and then start a graceful shutdown of the association.
135 remaining data in queue will be sent after which the association
139 is used to immediately terminate an association.
141 is sent to the peer and the local TCB is destroyed.
144 is used to specify that the message being sent has no
145 specific order and should be delivered to the peer application
147 When this flag is absent messages
148 are delivered in order within the stream they are sent, but without
149 respect to order to peer streams.
153 is used to specify that a specific address should be used.
155 SCTP will use only one of a multi-homed peers addresses as the primary
157 By default, no matter what the
159 argument is, this primary address is used to send data.
161 this flag, the user is asking the stack to ignore the primary address
162 and instead use the specified address not only as a lookup mechanism
163 to find the association but also as the actual address to send to.
165 For a one-to-many type (SOCK_SEQPACKET) socket the flag
167 can be used as a convenient way to make one send call and have
168 all associations that are under the socket get a copy of the message.
169 Note that this mechanism is quite efficient and makes only one actual
170 copy of the data which is shared by all the associations for sending.
172 The remaining flags are used for the partial reliability extension (RFC3758)
173 and will only be effective if the peer endpoint supports this extension.
174 This option specifies what local policy the local endpoint should use
176 If none of these options are set, then data is
180 is used to indicate that a time based lifetime is being applied
183 .Fa sinfo->sinfo_timetolive
184 argument is then a number of milliseconds for which the data is
185 attempted to be transmitted.
186 If that many milliseconds elapse
187 and the peer has not acknowledged the data, the data will be
188 skipped and no longer transmitted.
189 Note that this policy does
190 not even assure that the data will ever be sent.
191 In times of a congestion
192 with large amounts of data being queued, the
193 .Fa sinfo->sinfo_timetolive
194 may expire before the first transmission is ever made.
198 based policy transforms the
199 .Fa sinfo->sinfo_timetolive
200 field into a total number of bytes allowed on the outbound
202 If that number or more bytes are in queue, then
203 other buffer-based sends are looked to be removed and
205 Note that this policy may also result in the data
206 never being sent if no buffer based sends are in queue and
207 the maximum specified by
213 policy transforms the
214 .Fa sinfo->sinfo_timetolive
215 into a number of retransmissions to allow.
217 always assures that at a minimum one send attempt is
219 After which no more than
220 .Fa sinfo->sinfo_timetolive
221 retransmissions will be made before the data is skipped.
223 .Fa sinfo->sinfo_stream
224 is the SCTP stream that you wish to send the
226 Streams in SCTP are reliable (or partially reliable) flows of ordered
230 .Fa sinfo->sinfo_assoc_id
232 select the association to send to on a one-to-many socket.
233 For a one-to-one socket, this field is ignored.
236 .Fa sinfo->sinfo_context
237 field is used only in the event the message cannot be sent.
239 value that the stack retains and will give to the user when a failed send
240 is given if that notification is enabled (see
242 Normally a user process can use this value to index some application
243 specific data structure when a send cannot be fulfilled.
247 argument holds the same meaning and values as those found in
249 but is generally ignored by SCTP.
252 .Fa sinfo->sinfo_ssn ,
253 .Fa sinfo->sinfo_tsn ,
255 .Fa sinfo->sinfo_cumtsn
256 are used only when receiving messages and are thus ignored by
260 has the same properties as
262 with the additional arguments of an array of sockaddr structures
266 argument being given as an array of addresses to be sent to and
269 argument indicating how many socket addresses are in the passed
271 Note that all of the addresses will only be used
272 when an implicit association is being set up.
274 user the equivalent behavior as doing a
280 .Fa sinfo->sinfo_assoc_id
281 field is 0, then the first address will be used to look up
282 the association in place of the association id.
284 an address and an association id are specified, the association
287 The call returns the number of characters sent, or -1
288 if an error occurred.
296 An invalid descriptor was specified.
302 An invalid user space address was specified for an argument.
304 The socket requires that message be sent atomically,
305 and the size of the message to be sent made this impossible.
307 The socket is marked non-blocking and the requested operation
310 The system was unable to allocate an internal buffer.
311 The operation may succeed when buffers become available.
313 The output queue for a network interface was full.
314 This generally indicates that the interface has stopped sending,
315 but may be caused by transient congestion.
316 .It Bq Er EHOSTUNREACH
317 The remote host was unreachable.
319 On a one-to-one style socket no association exists.
321 An abort was received by the stack while the user was
322 attempting to send data to the peer.
324 On a one-to-many style socket no address is specified
325 so that the association cannot be located or the
326 SCTP_ABORT flag was specified on a non-existing association.
328 The socket is unable to send anymore data
329 .Dv ( SBS_CANTSENDMORE
330 has been set on the socket).
331 This typically means that the socket
332 is not connected and is a one-to-one style socket.
341 .Xr sctp_connectx 3 ,
348 may have multiple associations under one endpoint, a
349 select on write will only work for a one-to-one style