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

setsockopt.3p (4720B)


  1. '\" et
  2. .TH SETSOCKOPT "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. setsockopt
  12. \(em set the socket options
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <sys/socket.h>
  17. .P
  18. int setsockopt(int \fIsocket\fP, int \fIlevel\fP, int \fIoption_name\fP,
  19. const void *\fIoption_value\fP, socklen_t \fIoption_len\fP);
  20. .fi
  21. .SH DESCRIPTION
  22. The
  23. \fIsetsockopt\fR()
  24. function shall set the option specified by the
  25. .IR option_name
  26. argument, at the protocol level specified by the
  27. .IR level
  28. argument, to the value pointed to by the
  29. .IR option_value
  30. argument for the socket associated with the file descriptor specified
  31. by the
  32. .IR socket
  33. argument.
  34. .P
  35. The
  36. .IR level
  37. argument specifies the protocol level at which the option resides. To
  38. set options at the socket level, specify the
  39. .IR level
  40. argument as SOL_SOCKET. To set options at other levels, supply the
  41. appropriate
  42. .IR level
  43. identifier for the protocol controlling the option. For example, to
  44. indicate that an option is interpreted by the TCP (Transport Control
  45. Protocol), set
  46. .IR level
  47. to IPPROTO_TCP as defined in the
  48. .IR <netinet/in.h>
  49. header.
  50. .P
  51. The
  52. .IR option_name
  53. argument specifies a single option to set. It can be one of the
  54. socket-level options defined in
  55. .IR "\fB<sys_socket.h>\fP"
  56. and described in
  57. .IR "Section 2.10.16" ", " "Use of Options".
  58. If
  59. .IR option_name
  60. is equal to SO_RCVTIMEO or SO_SNDTIMEO and the implementation supports
  61. setting the option, it is unspecified whether the
  62. .BR "struct timeval"
  63. pointed to by
  64. .IR option_value
  65. is stored as provided by this function or is rounded up to align with
  66. the resolution of the clock being used. If
  67. \fIsetsockopt\fR()
  68. is called with
  69. .IR option_name
  70. equal to SO_ACCEPTCONN, SO_ERROR, or SO_TYPE, the behavior is unspecified.
  71. .SH "RETURN VALUE"
  72. Upon successful completion,
  73. \fIsetsockopt\fR()
  74. shall return 0. Otherwise, \-1 shall be returned and
  75. .IR errno
  76. set to indicate the error.
  77. .SH ERRORS
  78. The
  79. \fIsetsockopt\fR()
  80. function shall fail if:
  81. .TP
  82. .BR EBADF
  83. The
  84. .IR socket
  85. argument is not a valid file descriptor.
  86. .TP
  87. .BR EDOM
  88. The send and receive timeout values are too big to fit into the timeout
  89. fields in the socket structure.
  90. .TP
  91. .BR EINVAL
  92. The specified option is invalid at the specified socket level or the
  93. socket has been shut down.
  94. .TP
  95. .BR EISCONN
  96. The socket is already connected, and a specified option cannot be set
  97. while the socket is connected.
  98. .TP
  99. .BR ENOPROTOOPT
  100. .br
  101. The option is not supported by the protocol.
  102. .TP
  103. .BR ENOTSOCK
  104. The
  105. .IR socket
  106. argument does not refer to a socket.
  107. .P
  108. The
  109. \fIsetsockopt\fR()
  110. function may fail if:
  111. .TP
  112. .BR ENOMEM
  113. There was insufficient memory available for the operation to complete.
  114. .TP
  115. .BR ENOBUFS
  116. Insufficient resources are available in the system to complete the
  117. call.
  118. .LP
  119. .IR "The following sections are informative."
  120. .SH "EXAMPLES"
  121. None.
  122. .SH "APPLICATION USAGE"
  123. The
  124. \fIsetsockopt\fR()
  125. function provides an application program with the means to control
  126. socket behavior. An application program can use
  127. \fIsetsockopt\fR()
  128. to allocate buffer space, control timeouts, or permit socket data
  129. broadcasts. The
  130. .IR <sys/socket.h>
  131. header defines the socket-level options available to
  132. \fIsetsockopt\fR().
  133. .P
  134. Options may exist at multiple protocol levels. The SO_ options are
  135. always present at the uppermost socket level.
  136. .SH "RATIONALE"
  137. None.
  138. .SH "FUTURE DIRECTIONS"
  139. None.
  140. .SH "SEE ALSO"
  141. .IR "Section 2.10" ", " "Sockets",
  142. .IR "\fIbind\fR\^(\|)",
  143. .IR "\fIendprotoent\fR\^(\|)",
  144. .IR "\fIgetsockopt\fR\^(\|)",
  145. .IR "\fIsocket\fR\^(\|)"
  146. .P
  147. The Base Definitions volume of POSIX.1\(hy2017,
  148. .IR "\fB<netinet_in.h>\fP",
  149. .IR "\fB<sys_socket.h>\fP"
  150. .\"
  151. .SH COPYRIGHT
  152. Portions of this text are reprinted and reproduced in electronic form
  153. from IEEE Std 1003.1-2017, Standard for Information Technology
  154. -- Portable Operating System Interface (POSIX), The Open Group Base
  155. Specifications Issue 7, 2018 Edition,
  156. Copyright (C) 2018 by the Institute of
  157. Electrical and Electronics Engineers, Inc and The Open Group.
  158. In the event of any discrepancy between this version and the original IEEE and
  159. The Open Group Standard, the original IEEE and The Open Group Standard
  160. is the referee document. The original Standard can be obtained online at
  161. http://www.opengroup.org/unix/online.html .
  162. .PP
  163. Any typographical or formatting errors that appear
  164. in this page are most likely
  165. to have been introduced during the conversion of the source files to
  166. man page format. To report such errors, see
  167. https://www.kernel.org/doc/man-pages/reporting_bugs.html .