sctp_sendmsg.3 (0add3200d178976b95848eff050d419cf4062520) sctp_sendmsg.3 (d8b5fd91b9011a1c21b7389e2dade6b9b1f6e425)
1.\" Copyright (c) 1983, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.

--- 22 unchanged lines hidden (view full) ---

31.\"
32.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
33.\" $FreeBSD$
34.\"
35.Dd December 15, 2006
36.Dt SCTP_SENDMSG 3
37.Os
38.Sh NAME
1.\" Copyright (c) 1983, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.

--- 22 unchanged lines hidden (view full) ---

31.\"
32.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
33.\" $FreeBSD$
34.\"
35.Dd December 15, 2006
36.Dt SCTP_SENDMSG 3
37.Os
38.Sh NAME
39.Nm sctp_sendmsg ,
39.Nm sctp_sendmsg
40.Nm sctp_sendmsgx
41.Nd send a message from an SCTP socket
42.Sh LIBRARY
43.Lb libc
44.Sh SYNOPSIS
45.In sys/types.h
46.In sys/socket.h
40.Nm sctp_sendmsgx
41.Nd send a message from an SCTP socket
42.Sh LIBRARY
43.Lb libc
44.Sh SYNOPSIS
45.In sys/types.h
46.In sys/socket.h
47.In netinet/sctp.h
47.In sys/sctp.h
48.Ft ssize_t
48.Ft ssize_t
49.Fo sctp_sendmsg
50.Fa "int s" "const void *msg" "size_t len" "const struct sockaddr *to"
51.Fa "socklen_t tolen" "uint32_t ppid" "uint32_t flags" "uint16_t stream_no"
52.Fa "uint32_t timetolive" "uint32_t context"
53.Fc
49.Fn sctp_sendmsg "int s" "const void *msg" "size_t len" "const struct sockaddr *to" "socklen_t tolen" "uint32_t ppid" "uint32_t flags" "uint16_t stream_no" "uint32_t timetolive" "uint32_t context"
54.Ft ssize_t
50.Ft ssize_t
55.Fo sctp_sendmsgx
56.Fa "int s" "const void *msg" "size_t len" "const struct sockaddr *to"
57.Fa "int addrcnt" "uint32_t ppid" "uint32_t flags" "uint16_t stream_no"
58.Fa "uint32_t timetolive" "uint32_t context"
59.Fc
51.Fn sctp_sendmsgx "int s" "const void *msg" "size_t len" "const struct sockaddr *to" "int addrcnt" "uint32_t ppid" "uint32_t flags" "uint16_t stream_no" "uint32_t timetolive" "uint32_t context"
52
60.Sh DESCRIPTION
61The
62.Fn sctp_sendmsg
53.Sh DESCRIPTION
54The
55.Fn sctp_sendmsg
63system call
56system calls
64is used to transmit a message to another SCTP endpoint.
65The
66.Fn sctp_sendmsg
57is used to transmit a message to another SCTP endpoint.
58The
59.Fn sctp_sendmsg
67may be used at any time.
68If the socket is a one-to-many type (SOCK_SEQPACKET)
60may be used at any time. If the socket is a one-to-many type (SOCK_SEQPACKET)
69socket then an attempt to send to an address that no association exists to will
61socket then an attempt to send to an address that no association exists to will
70implicitly create a new association.
71Data sent in such an instance will result in
72the data being sent on the third leg of the SCTP four-way handshake.
73Note that if
62implicitly create a new association. Data sent in such an instance will result in
63the data being sent on the third leg of the SCTP four-way handshake. Note that if
74the socket is a one-to-one type (SOCK_STREAM) socket then an association must
75be in existance (by use of the
64the socket is a one-to-one type (SOCK_STREAM) socket then an association must
65be in existance (by use of the
76.Xr connect 2
77system call).
78Calling
66.Fn connect 2
67system call). Calling
79.Fn sctp_sendmsg
80or
81.Fn sctp_sendmsgx
68.Fn sctp_sendmsg
69or
70.Fn sctp_sendmsgx
82on a non-connected one-to-one socket will result in
83.Va errno
84being set to
85.Er ENOTCONN ,
86-1 being returned, and the message not being transmitted.
71on a non-connected one-to-one socket will result in the errno being set to
72.Er ENOTCONN
73a -1 being returned, and the message is not transmitted.
87.Pp
88The address of the target is given by
89.Fa to
90with
91.Fa tolen
92specifying its size.
93The length of the message
94.Fa msg
95is given by
96.Fa len .
97If the message is too long to pass atomically through the
74.Pp
75The address of the target is given by
76.Fa to
77with
78.Fa tolen
79specifying its size.
80The length of the message
81.Fa msg
82is given by
83.Fa len .
84If the message is too long to pass atomically through the
98underlying protocol,
99.Va errno
100is set to
101.Er EMSGSIZE ,
102-1 is returned, and
85underlying protocol, the errno is set to
86.Er EMSGSIZE
87a -1 is returned, and
103the message is not transmitted.
104.Pp
105No indication of failure to deliver is implicit in a
88the message is not transmitted.
89.Pp
90No indication of failure to deliver is implicit in a
106.Xr sctp_sendmsg 3
107call.
91.Fn sctp_sendmsg 2
108Locally detected errors are indicated by a return value of -1.
109.Pp
92Locally detected errors are indicated by a return value of -1.
93.Pp
110If no space is available at the socket to hold
94If no messages space is available at the socket to hold
111the message to be transmitted, then
95the message to be transmitted, then
112.Xr sctp_sendmsg 3
96.Fn sctp_sendmsg 2
113normally blocks, unless the socket has been placed in
114non-blocking I/O mode.
115The
97normally blocks, unless the socket has been placed in
98non-blocking I/O mode.
99The
116.Xr select 2
100.Fn select 2
117system call may be used to determine when it is possible to
118send more data on one-to-one type (SOCK_STREAM) sockets.
119.Pp
120The
121.Fa ppid
122argument is an opaque 32 bit value that is passed transparently
101system call may be used to determine when it is possible to
102send more data on one-to-one type (SOCK_STREAM) sockets.
103.Pp
104The
105.Fa ppid
106argument is an opaque 32 bit value that is passed transparently
123through the stack to the peer endpoint.
124It will be available on
107through the stack to the peer endpoint. It will be available on
125reception of a message (see
108reception of a message (see
126.Xr sctp_recvmsg 3 ) .
127Note that the stack passes this value without regard to byte
109.Fn sctp_recvmsg 2
110). Note that the stack passes this value without regard to byte
128order.
129.Pp
130The
131.Fa flags
132argument may include one or more of the following:
133.Bd -literal
134#define SCTP_EOF 0x0100 /* Start a shutdown procedures */
135#define SCTP_ABORT 0x0200 /* Send an ABORT to peer */

--- 5 unchanged lines hidden (view full) ---

141#define SCTP_PR_SCTP_TTL 0x0001 /* Time based PR-SCTP */
142#define SCTP_PR_SCTP_BUF 0x0002 /* Buffer based PR-SCTP */
143#define SCTP_PR_SCTP_RTX 0x0003 /* Number of retransmissions based PR-SCTP */
144.Ed
145.Pp
146The flag
147.Dv SCTP_EOF
148is used to instruct the SCTP stack to queue this message
111order.
112.Pp
113The
114.Fa flags
115argument may include one or more of the following:
116.Bd -literal
117#define SCTP_EOF 0x0100 /* Start a shutdown procedures */
118#define SCTP_ABORT 0x0200 /* Send an ABORT to peer */

--- 5 unchanged lines hidden (view full) ---

124#define SCTP_PR_SCTP_TTL 0x0001 /* Time based PR-SCTP */
125#define SCTP_PR_SCTP_BUF 0x0002 /* Buffer based PR-SCTP */
126#define SCTP_PR_SCTP_RTX 0x0003 /* Number of retransmissions based PR-SCTP */
127.Ed
128.Pp
129The flag
130.Dv SCTP_EOF
131is used to instruct the SCTP stack to queue this message
149and then start a graceful shutdown of the association.
150All
132and then start a graceful shutdown of the association. All
151remaining data in queue will be sent after which the association
133remaining data in queue will be sent after which the association
152will be shut down.
134will be shutdown.
153.Pp
154.Dv SCTP_ABORT
135.Pp
136.Dv SCTP_ABORT
155is used to immediately terminate an association.
156An abort
137is used to immediately terminate an association. An abort
157is sent to the peer and the local TCB is destroyed.
158.Pp
159.Dv SCTP_UNORDERED
160is used to specify that the message being sent has no
161specific order and should be delivered to the peer application
138is sent to the peer and the local TCB is destroyed.
139.Pp
140.Dv SCTP_UNORDERED
141is used to specify that the message being sent has no
142specific order and should be delivered to the peer application
162as soon as possible.
163When this flag is absent messages
143as soon as possible. When this flag is absent messages
164are delivered in order within the stream they are sent, but without
165respect to order to peer streams.
166.Pp
167The flag
168.Dv SCTP_ADDR_OVER
144are delivered in order within the stream they are sent, but without
145respect to order to peer streams.
146.Pp
147The flag
148.Dv SCTP_ADDR_OVER
169is used to specify that an specific address should be used.
170Normally
171SCTP will use only one of a multi-homed peers addresses as the primary
172address to send to.
173By default, no matter what the
149is used to specify that an specific address should be used. Normally
150SCTP will use only one of a multi-homed peers address as the primary
151address to send to. By default, no matter what the
174.Fa to
152.Fa to
175argument is, this primary address is used to send data.
176By specifying
153argument is, this primary address is used to send data. By specifying
177this flag, the user is asking the stack to ignore the primary address
154this flag, the user is asking the stack to ignore the primary address
178and instead use the specified address not only as a lookup mechanism
179to find the association but also as the actual address to send to.
155and instead use the specified address not only has a lookup mechanism
156to find the association but also has the actual address to send to.
180.Pp
181For a one-to-many type (SOCK_SEQPACKET) socket the flag
182.Dv SCTP_SENDALL
183can be used as a convient way to make one send call and have
184all associations that are under the socket get a copy of the message.
185Note that this mechanism is quite efficent and makes only one actual
186copy of the data which is shared by all the associations for sending.
187.Pp
157.Pp
158For a one-to-many type (SOCK_SEQPACKET) socket the flag
159.Dv SCTP_SENDALL
160can be used as a convient way to make one send call and have
161all associations that are under the socket get a copy of the message.
162Note that this mechanism is quite efficent and makes only one actual
163copy of the data which is shared by all the associations for sending.
164.Pp
188The remaining flags are used for the partial reliability extension (RFC3758)
165The remaining flags are used for the partial reliabilty extension (RFC3758)
189and will only be effective if the peer endpoint supports this extension.
166and will only be effective if the peer endpoint supports this extension.
190This option specifies what local policy the local endpoint should use
191in skipping data.
192If none of these options are set, then data is
167This option specify's what local policy the local endpoint should use
168in skipping data. If none of these options are set, then data is
193never skipped over.
194.Pp
195.Dv SCTP_PR_SCTP_TTL
169never skipped over.
170.Pp
171.Dv SCTP_PR_SCTP_TTL
196is used to indicate that a time based lifetime is being applied
197to the data.
198The
172Is used to indicate that a time based lifetime is being applied
173to the data. The
199.Fa timetolive
200argument is then a number of milliseconds for which the data is
174.Fa timetolive
175argument is then a number of milliseconds for which the data is
201attempted to be transmitted.
202If that many milliseconds ellapse
203and the peer has not acknowledged the data, the data will be
204skipped and no longer transmitted.
205Note that this policy does
206not even assure that the data will ever be sent.
207In times of a congestion
176attempted to be transmitted. If that many milliseconds ellapses
177and the peer has not acknowledge the data, the data will be
178skipped and no longer transmitted. Note that this policy does
179not even assure that the data will ever be sent. In times of a congestion
208with large amounts of data being queued, the
209.Fa timetolive
210may expire before the first transmission is ever made.
211.Pp
212The
213.Dv SCTP_PR_SCTP_BUF
214based policy transforms the
215.Fa timetolive
216field into a total number of bytes allowed on the outbound
180with large amounts of data being queued, the
181.Fa timetolive
182may expire before the first transmission is ever made.
183.Pp
184The
185.Dv SCTP_PR_SCTP_BUF
186based policy transforms the
187.Fa timetolive
188field into a total number of bytes allowed on the outbound
217send queue.
218If that number or more bytes are in queue, then
189send queue. If that number or more bytes are in queue, then
219other buffer based sends are looked to be removed and
190other buffer based sends are looked to be removed and
220skipped.
221Note that this policy may also result in the data
191skipped. Note that this policy may also result in the data
222never being sent if no buffer based sends are in queue and
223the maximum specified by
224.Fa timetolive
225bytes is in queue.
226.Pp
227The
228.Dv SCTP_PR_SCTP_RTX
229policy transforms the
230.Fa timetolive
192never being sent if no buffer based sends are in queue and
193the maximum specified by
194.Fa timetolive
195bytes is in queue.
196.Pp
197The
198.Dv SCTP_PR_SCTP_RTX
199policy transforms the
200.Fa timetolive
231into a number of retransmissions to allow.
232This policy
201into a number of retransmissions to allow. This policy
233always assures that at a minimum one send attempt is
202always assures that at a minimum one send attempt is
234made of the data.
235After which no more than
203made of the data. After which no more than
236.Fa timetolive
237retransmissions will be made before the data is skipped.
238.Pp
239.Fa stream_no
240is the SCTP stream that you wish to send the
204.Fa timetolive
205retransmissions will be made before the data is skipped.
206.Pp
207.Fa stream_no
208is the SCTP stream that you wish to send the
241message on.
242Streams in SCTP are reliable (or partially reliable) flows of ordered
243messages.
244The
209message on. Streams in SCTP are reliable (or partially reliable) flows of ordered
210messages. The
245.Fa context
211.Fa context
246field is used only in the event the message cannot be sent.
247This is an opaque
212field is used only in the event the message cannot be sent. This is an opaque
248value that the stack retains and will give to the user when a failed send
249is given if that notification is enabled (see
213value that the stack retains and will give to the user when a failed send
214is given if that notification is enabled (see
250.Xr sctp 4 ) .
251Normally a user process can use this value to index some application
215.Tn sctp
216). Normally a user process can use this value to index some application
252specific data structure when a send cannot be fulfilled.
253.Fn sctp_sendmsgx
254is identical to
255.Fn sctp_sendmsg
217specific data structure when a send cannot be fulfilled.
218.Fn sctp_sendmsgx
219is identical to
220.Fn sctp_sendmsg
256with the exception that it takes an array of sockaddr structures in the
221with the exception that it takes a array of sockaddr structures in the
257argument
258.Fa to
259and adds the additional argument
260.Fa addrcnt
222argument
223.Fa to
224and adds the additional argument
225.Fa addrcnt
261which specifies how many addresses are in the array.
262This allows a
263caller to implicitly set up an association passing multiple addresses
264as if
226which specifies how many addresses are in the array. This allows a
227caller to implictly setup an association passing multiple addresses
228as if an
265.Fn sctp_connectx
229.Fn sctp_connectx
266had been called to set up the association.
230had been called to setup the association.
267.Sh RETURN VALUES
268The call returns the number of characters sent, or -1
269if an error occurred.
270.Sh ERRORS
271The
231.Sh RETURN VALUES
232The call returns the number of characters sent, or -1
233if an error occurred.
234.Sh ERRORS
235The
272.Fn sctp_sendmsg
236.Fn sctp_sendmsg 2
273system call
237system call
274fails if:
238fail if:
275.Bl -tag -width Er
276.It Bq Er EBADF
277An invalid descriptor was specified.
278.It Bq Er ENOTSOCK
279The argument
280.Fa s
281is not a socket.
282.It Bq Er EFAULT

--- 8 unchanged lines hidden (view full) ---

291The system was unable to allocate an internal buffer.
292The operation may succeed when buffers become available.
293.It Bq Er ENOBUFS
294The output queue for a network interface was full.
295This generally indicates that the interface has stopped sending,
296but may be caused by transient congestion.
297.It Bq Er EHOSTUNREACH
298The remote host was unreachable.
239.Bl -tag -width Er
240.It Bq Er EBADF
241An invalid descriptor was specified.
242.It Bq Er ENOTSOCK
243The argument
244.Fa s
245is not a socket.
246.It Bq Er EFAULT

--- 8 unchanged lines hidden (view full) ---

255The system was unable to allocate an internal buffer.
256The operation may succeed when buffers become available.
257.It Bq Er ENOBUFS
258The output queue for a network interface was full.
259This generally indicates that the interface has stopped sending,
260but may be caused by transient congestion.
261.It Bq Er EHOSTUNREACH
262The remote host was unreachable.
299.It Bq Er ENOTCONN
300On a one-to-one style socket no association exists.
263.It Bq Er ENOTCON
264On a one to one style socket no association exists.
301.It Bq Er ECONNRESET
302An abort was received by the stack while the user was
303attempting to send data to the peer.
304.It Bq Er ENOENT
265.It Bq Er ECONNRESET
266An abort was received by the stack while the user was
267attempting to send data to the peer.
268.It Bq Er ENOENT
305On a one-to-many style socket no address is specified
269On a one to many style socket no address is specified
306so that the association cannot be located or the
270so that the association cannot be located or the
307.Dv SCTP_ABORT
308flag was specified on a non-existing association.
271SCTP_ABORT flag was specified on a non-existing association.
309.It Bq Er EPIPE
310The socket is unable to send anymore data
311.Dv ( SBS_CANTSENDMORE
312has been set on the socket).
313This typically means that the socket
314is not connected and is a one-to-one style socket.
315.El
316.Sh SEE ALSO
272.It Bq Er EPIPE
273The socket is unable to send anymore data
274.Dv ( SBS_CANTSENDMORE
275has been set on the socket).
276This typically means that the socket
277is not connected and is a one-to-one style socket.
278.El
279.Sh SEE ALSO
280.Xr sctp 4 ,
281.Xr sendmsg 3 ,
317.Xr connect 2 ,
282.Xr connect 2 ,
283.Xr sctp_connectx 3 ,
318.Xr getsockopt 2 ,
319.Xr recv 2 ,
320.Xr select 2 ,
321.Xr socket 2 ,
284.Xr getsockopt 2 ,
285.Xr recv 2 ,
286.Xr select 2 ,
287.Xr socket 2 ,
322.Xr write 2 ,
323.Xr sctp_connectx 3 ,
324.Xr sendmsg 3 ,
325.Xr sctp 4
288.Xr write 2
326.Sh BUGS
289.Sh BUGS
327Because in the one-to-many style socket
290Because in the one-to-many style socket the
328.Fn sctp_sendmsg
329or
330.Fn sctp_sendmsgx
331may have multiple associations under one endpoint, a
332select on write will only work for a one-to-one style
333socket.
291.Fn sctp_sendmsg
292or
293.Fn sctp_sendmsgx
294may have multiple associations under one endpoint, a
295select on write will only work for a one-to-one style
296socket.
297