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

socket.3p (5706B)


  1. '\" et
  2. .TH SOCKET "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. socket
  12. \(em create an endpoint for communication
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <sys/socket.h>
  17. .P
  18. int socket(int \fIdomain\fP, int \fItype\fP, int \fIprotocol\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIsocket\fR()
  23. function shall create an unbound socket in a communications domain, and
  24. return a file descriptor that can be used in later function calls that
  25. operate on sockets. The file descriptor shall be allocated as described in
  26. .IR "Section 2.14" ", " "File Descriptor Allocation".
  27. .P
  28. The
  29. \fIsocket\fR()
  30. function takes the following arguments:
  31. .IP "\fIdomain\fR" 12
  32. Specifies the communications domain in which a socket is to be
  33. created.
  34. .IP "\fItype\fR" 12
  35. Specifies the type of socket to be created.
  36. .IP "\fIprotocol\fR" 12
  37. Specifies a particular protocol to be used with the socket. Specifying
  38. a
  39. .IR protocol
  40. of 0 causes
  41. \fIsocket\fR()
  42. to use an unspecified default protocol appropriate for the requested
  43. socket type.
  44. .P
  45. The
  46. .IR domain
  47. argument specifies the address family used in the communications
  48. domain. The address families supported by the system are
  49. implementation-defined.
  50. .P
  51. Symbolic constants that can be used for the domain argument are defined
  52. in the
  53. .IR <sys/socket.h>
  54. header.
  55. .P
  56. The
  57. .IR type
  58. argument specifies the socket type, which determines the semantics of
  59. communication over the socket. The following socket types are defined;
  60. implementations may specify additional socket types:
  61. .IP SOCK_STREAM 12
  62. Provides sequenced, reliable, bidirectional, connection-mode byte
  63. streams, and may provide a transmission mechanism for out-of-band
  64. data.
  65. .IP SOCK_DGRAM 12
  66. Provides datagrams, which are connectionless-mode, unreliable messages
  67. of fixed maximum length.
  68. .IP SOCK_SEQPACKET 12
  69. .br
  70. Provides sequenced, reliable, bidirectional, connection-mode
  71. transmission paths for records. A record can be sent using one or more
  72. output operations and received using one or more input operations, but
  73. a single operation never transfers part of more than one record. Record
  74. boundaries are visible to the receiver via the MSG_EOR flag.
  75. .P
  76. If the
  77. .IR protocol
  78. argument is non-zero, it shall specify a protocol that is supported by
  79. the address family. If the
  80. .IR protocol
  81. argument is zero, the default protocol for this address family and type
  82. shall be used. The protocols supported by the system are
  83. implementation-defined.
  84. .P
  85. The process may need to have appropriate privileges to use the
  86. \fIsocket\fR()
  87. function or to create some sockets.
  88. .SH "RETURN VALUE"
  89. Upon successful completion,
  90. \fIsocket\fR()
  91. shall return a non-negative integer, the socket file descriptor.
  92. Otherwise, a value of \-1 shall be returned and
  93. .IR errno
  94. set to indicate the error.
  95. .br
  96. .SH ERRORS
  97. The
  98. \fIsocket\fR()
  99. function shall fail if:
  100. .TP
  101. .BR EAFNOSUPPORT
  102. .br
  103. The implementation does not support the specified address family.
  104. .TP
  105. .BR EMFILE
  106. All file descriptors available to the process are currently open.
  107. .TP
  108. .BR ENFILE
  109. No more file descriptors are available for the system.
  110. .TP
  111. .BR EPROTONOSUPPORT
  112. .br
  113. The protocol is not supported by the address family, or the protocol is
  114. not supported by the implementation.
  115. .TP
  116. .BR EPROTOTYPE
  117. The socket type is not supported by the protocol.
  118. .P
  119. The
  120. \fIsocket\fR()
  121. function may fail if:
  122. .TP
  123. .BR EACCES
  124. The process does not have appropriate privileges.
  125. .TP
  126. .BR ENOBUFS
  127. Insufficient resources were available in the system to perform the
  128. operation.
  129. .TP
  130. .BR ENOMEM
  131. Insufficient memory was available to fulfill the request.
  132. .LP
  133. .IR "The following sections are informative."
  134. .SH "EXAMPLES"
  135. None.
  136. .SH "APPLICATION USAGE"
  137. The documentation for specific address families specifies which
  138. protocols each address family supports. The documentation for specific
  139. protocols specifies which socket types each protocol supports.
  140. .P
  141. The application can determine whether an address family is supported by
  142. trying to create a socket with
  143. .IR domain
  144. set to the protocol in question.
  145. .SH "RATIONALE"
  146. None.
  147. .SH "FUTURE DIRECTIONS"
  148. None.
  149. .SH "SEE ALSO"
  150. .IR "Section 2.14" ", " "File Descriptor Allocation",
  151. .IR "\fIaccept\fR\^(\|)",
  152. .IR "\fIbind\fR\^(\|)",
  153. .IR "\fIconnect\fR\^(\|)",
  154. .IR "\fIgetsockname\fR\^(\|)",
  155. .IR "\fIgetsockopt\fR\^(\|)",
  156. .IR "\fIlisten\fR\^(\|)",
  157. .IR "\fIrecv\fR\^(\|)",
  158. .IR "\fIrecvfrom\fR\^(\|)",
  159. .IR "\fIrecvmsg\fR\^(\|)",
  160. .IR "\fIsend\fR\^(\|)",
  161. .IR "\fIsendmsg\fR\^(\|)",
  162. .IR "\fIsetsockopt\fR\^(\|)",
  163. .IR "\fIshutdown\fR\^(\|)",
  164. .IR "\fIsocketpair\fR\^(\|)"
  165. .P
  166. The Base Definitions volume of POSIX.1\(hy2017,
  167. .IR "\fB<netinet_in.h>\fP",
  168. .IR "\fB<sys_socket.h>\fP"
  169. .\"
  170. .SH COPYRIGHT
  171. Portions of this text are reprinted and reproduced in electronic form
  172. from IEEE Std 1003.1-2017, Standard for Information Technology
  173. -- Portable Operating System Interface (POSIX), The Open Group Base
  174. Specifications Issue 7, 2018 Edition,
  175. Copyright (C) 2018 by the Institute of
  176. Electrical and Electronics Engineers, Inc and The Open Group.
  177. In the event of any discrepancy between this version and the original IEEE and
  178. The Open Group Standard, the original IEEE and The Open Group Standard
  179. is the referee document. The original Standard can be obtained online at
  180. http://www.opengroup.org/unix/online.html .
  181. .PP
  182. Any typographical or formatting errors that appear
  183. in this page are most likely
  184. to have been introduced during the conversion of the source files to
  185. man page format. To report such errors, see
  186. https://www.kernel.org/doc/man-pages/reporting_bugs.html .