logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

send.3p (6201B)


  1. '\" et
  2. .TH SEND "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. send
  12. \(em send a message on a socket
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <sys/socket.h>
  17. .P
  18. ssize_t send(int \fIsocket\fP, const void *\fIbuffer\fP, size_t \fIlength\fP, int \fIflags\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIsend\fR()
  23. function shall initiate transmission of a message from the specified
  24. socket to its peer. The
  25. \fIsend\fR()
  26. function shall send a message only when the socket is connected. If
  27. the socket is a connectionless-mode socket, the message shall be sent
  28. to the pre-specified peer address.
  29. .P
  30. The
  31. \fIsend\fR()
  32. function takes the following arguments:
  33. .IP "\fIsocket\fR" 12
  34. Specifies the socket file descriptor.
  35. .IP "\fIbuffer\fR" 12
  36. Points to the buffer containing the message to send.
  37. .IP "\fIlength\fR" 12
  38. Specifies the length of the message in bytes.
  39. .IP "\fIflags\fR" 12
  40. Specifies the type of message transmission. Values of this argument are
  41. formed by logically OR'ing zero or more of the following flags:
  42. .RS 12
  43. .IP MSG_EOR 14
  44. Terminates a record (if supported by the protocol).
  45. .IP MSG_OOB 14
  46. Sends out-of-band data on sockets that support out-of-band
  47. communications. The significance and semantics of out-of-band data are
  48. protocol-specific.
  49. .IP MSG_NOSIGNAL 14
  50. Requests not to send the SIGPIPE signal if an attempt to send is made
  51. on a stream-oriented socket that is no longer connected. The
  52. .BR [EPIPE]
  53. error shall still be returned.
  54. .RE
  55. .P
  56. The length of the message to be sent is specified by the
  57. .IR length
  58. argument. If the message is too long to pass through the underlying
  59. protocol,
  60. \fIsend\fR()
  61. shall fail and no data shall be transmitted.
  62. .P
  63. Successful completion of a call to
  64. \fIsend\fR()
  65. does not guarantee delivery of the message. A return value of \-1
  66. indicates only locally-detected errors.
  67. .P
  68. If space is not available at the sending socket to hold the message to
  69. be transmitted, and the socket file descriptor does not have O_NONBLOCK
  70. set,
  71. \fIsend\fR()
  72. shall block until space is available. If space is not available at the
  73. sending socket to hold the message to be transmitted, and the socket
  74. file descriptor does have O_NONBLOCK set,
  75. \fIsend\fR()
  76. shall fail. The
  77. \fIselect\fR()
  78. and
  79. \fIpoll\fR()
  80. functions can be used to determine when it is possible to send more
  81. data.
  82. .P
  83. The socket in use may require the process to have appropriate
  84. privileges to use the
  85. \fIsend\fR()
  86. function.
  87. .SH "RETURN VALUE"
  88. Upon successful completion,
  89. \fIsend\fR()
  90. shall return the number of bytes sent. Otherwise, \-1 shall be
  91. returned and
  92. .IR errno
  93. set to indicate the error.
  94. .SH ERRORS
  95. The
  96. \fIsend\fR()
  97. function shall fail if:
  98. .TP
  99. .BR EAGAIN " or " EWOULDBLOCK
  100. .br
  101. The socket's file descriptor is marked O_NONBLOCK and the requested
  102. operation would block.
  103. .TP
  104. .BR EBADF
  105. The
  106. .IR socket
  107. argument is not a valid file descriptor.
  108. .TP
  109. .BR ECONNRESET
  110. A connection was forcibly closed by a peer.
  111. .TP
  112. .BR EDESTADDRREQ
  113. .br
  114. The socket is not connection-mode and no peer address is set.
  115. .TP
  116. .BR EINTR
  117. A signal interrupted
  118. \fIsend\fR()
  119. before any data was transmitted.
  120. .TP
  121. .BR EMSGSIZE
  122. The message is too large to be sent all at once, as the socket requires.
  123. .TP
  124. .BR ENOTCONN
  125. The socket is not connected.
  126. .TP
  127. .BR ENOTSOCK
  128. The
  129. .IR socket
  130. argument does not refer to a socket.
  131. .TP
  132. .BR EOPNOTSUPP
  133. The
  134. .IR socket
  135. argument is associated with a socket that does not support one or more
  136. of the values set in
  137. .IR flags .
  138. .TP
  139. .BR EPIPE
  140. The socket is shut down for writing, or the socket is connection-mode
  141. and is no longer connected. In the latter case, and if the socket is of
  142. type SOCK_STREAM or SOCK_SEQPACKET and the MSG_NOSIGNAL flag is not set,
  143. the SIGPIPE signal is generated to the calling thread.
  144. .P
  145. The
  146. \fIsend\fR()
  147. function may fail if:
  148. .TP
  149. .BR EACCES
  150. The calling process does not have appropriate privileges.
  151. .TP
  152. .BR EIO
  153. An I/O error occurred while reading from or writing to the file system.
  154. .TP
  155. .BR ENETDOWN
  156. The local network interface used to reach the destination is down.
  157. .TP
  158. .BR ENETUNREACH
  159. .br
  160. No route to the network is present.
  161. .TP
  162. .BR ENOBUFS
  163. Insufficient resources were available in the system to perform the
  164. operation.
  165. .LP
  166. .IR "The following sections are informative."
  167. .SH "EXAMPLES"
  168. None.
  169. .SH "APPLICATION USAGE"
  170. If the
  171. .IR socket
  172. argument refers to a connection-mode socket, the
  173. \fIsend\fR()
  174. function is equivalent to
  175. \fIsendto\fR()
  176. (with any value for the
  177. .IR dest_addr
  178. and
  179. .IR dest_len
  180. arguments, as they are ignored in this case). If the
  181. .IR socket
  182. argument refers to a socket and the
  183. .IR flags
  184. argument is 0, the
  185. \fIsend\fR()
  186. function is equivalent to
  187. \fIwrite\fR().
  188. .SH "RATIONALE"
  189. None.
  190. .SH "FUTURE DIRECTIONS"
  191. None.
  192. .SH "SEE ALSO"
  193. .IR "\fIconnect\fR\^(\|)",
  194. .IR "\fIgetsockopt\fR\^(\|)",
  195. .IR "\fIpoll\fR\^(\|)",
  196. .IR "\fIpselect\fR\^(\|)",
  197. .IR "\fIrecv\fR\^(\|)",
  198. .IR "\fIrecvfrom\fR\^(\|)",
  199. .IR "\fIrecvmsg\fR\^(\|)",
  200. .IR "\fIsendmsg\fR\^(\|)",
  201. .IR "\fIsendto\fR\^(\|)",
  202. .IR "\fIsetsockopt\fR\^(\|)",
  203. .IR "\fIshutdown\fR\^(\|)",
  204. .IR "\fIsocket\fR\^(\|)",
  205. .IR "\fIwrite\fR\^(\|)"
  206. .P
  207. The Base Definitions volume of POSIX.1\(hy2017,
  208. .IR "\fB<sys_socket.h>\fP"
  209. .\"
  210. .SH COPYRIGHT
  211. Portions of this text are reprinted and reproduced in electronic form
  212. from IEEE Std 1003.1-2017, Standard for Information Technology
  213. -- Portable Operating System Interface (POSIX), The Open Group Base
  214. Specifications Issue 7, 2018 Edition,
  215. Copyright (C) 2018 by the Institute of
  216. Electrical and Electronics Engineers, Inc and The Open Group.
  217. In the event of any discrepancy between this version and the original IEEE and
  218. The Open Group Standard, the original IEEE and The Open Group Standard
  219. is the referee document. The original Standard can be obtained online at
  220. http://www.opengroup.org/unix/online.html .
  221. .PP
  222. Any typographical or formatting errors that appear
  223. in this page are most likely
  224. to have been introduced during the conversion of the source files to
  225. man page format. To report such errors, see
  226. https://www.kernel.org/doc/man-pages/reporting_bugs.html .