Print this page
3769 Implement SOCK_NONBLOCK flag to socket()
Reviewed-by: Robert Mustacchi <rm@joyent.com>


  83 .fi
  84 .in -2
  85 
  86 .sp
  87 .LP
  88 The \fItype\fR may be augmented by a bitwise-inclusive-OR of flags from the
  89 following list, defined in <sys/socket.h>.
  90 
  91 .sp
  92 .ne 2
  93 .na
  94 \fB\fBSOCK_CLOEXEC\fR\fR
  95 .ad
  96 .RS 12n
  97 Creates the socket with the \fBFD_CLOEXEC\fR flag set, causing the underlying
  98 file descriptor to be closed prior to any future calls to \fBexec\fR(2). This
  99 is similar in purpose to the \fBO_CLOEXEC\fR flag to \fBopen\fR(2).
 100 .RE
 101 
 102 .sp






















 103 .LP
 104 There must be an entry in the \fBnetconfig\fR(4) file for at least each
 105 protocol family and type required. If  a non-zero protocol has been specified
 106 but no exact match for the protocol family, type, and protocol is found, then
 107 the first entry containing the specified family and type with a \fIprotocol\fR
 108 value of zero will be used.
 109 .sp
 110 .LP
 111 A \fBSOCK_STREAM\fR type provides sequenced, reliable, two-way connection-based
 112 byte streams. An out-of-band data transmission mechanism may be supported. A
 113 \fBSOCK_DGRAM\fR socket supports datagrams (connectionless, unreliable messages
 114 of a fixed (typically small) maximum length). A \fBSOCK_SEQPACKET\fR socket may
 115 provide a sequenced, reliable, two-way connection-based data transmission path
 116 for datagrams of fixed maximum length; a consumer may be required to read an
 117 entire packet with each read system call. This facility is protocol specific,
 118 and presently not implemented for any protocol family. \fBSOCK_RAW\fR sockets
 119 provide access to internal network interfaces. The types \fBSOCK_RAW\fR, which
 120 is available only to a user with the \fBnet_rawaccess\fR privilege, and
 121 \fBSOCK_RDM\fR, for which no implementation currently exists, are not described
 122 here.


 247 .RE
 248 
 249 .sp
 250 .ne 2
 251 .na
 252 \fB\fBEPROTONOSUPPORT\fR\fR
 253 .ad
 254 .RS 19n
 255 The protocol type is not supported by the address family.
 256 .RE
 257 
 258 .sp
 259 .ne 2
 260 .na
 261 \fB\fBEPROTOTYPE\fR\fR
 262 .ad
 263 .RS 19n
 264 The socket type is not supported by the protocol.
 265 .RE
 266 









 267 .SH ATTRIBUTES
 268 .sp
 269 .LP
 270 See \fBattributes\fR(5) for descriptions of the following attributes:
 271 .sp
 272 
 273 .sp
 274 .TS
 275 box;
 276 c | c
 277 l | l .
 278 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 279 _
 280 MT-Level        Safe
 281 .TE
 282 
 283 .SH SEE ALSO
 284 .sp
 285 .LP
 286 \fBnca\fR(1), \fBclose\fR(2), \fBfcntl\fR(2), \fBioctl\fR(2), \fBread\fR(2),


  83 .fi
  84 .in -2
  85 
  86 .sp
  87 .LP
  88 The \fItype\fR may be augmented by a bitwise-inclusive-OR of flags from the
  89 following list, defined in <sys/socket.h>.
  90 
  91 .sp
  92 .ne 2
  93 .na
  94 \fB\fBSOCK_CLOEXEC\fR\fR
  95 .ad
  96 .RS 12n
  97 Creates the socket with the \fBFD_CLOEXEC\fR flag set, causing the underlying
  98 file descriptor to be closed prior to any future calls to \fBexec\fR(2). This
  99 is similar in purpose to the \fBO_CLOEXEC\fR flag to \fBopen\fR(2).
 100 .RE
 101 
 102 .sp
 103 .ne 2
 104 .na
 105 \fB\fBSOCK_NDELAY\fR\fR
 106 .ad
 107 .RS 12n
 108 Creates the socket with the \fBO_NDELAY\fR flag set, causing the socket to
 109 provide nonblocking semantics as described for \fBO_NDELAY\fR in \fBopen\fR(2).
 110 \fBSOCK_NONBLOCK\fR should normally be used in preference to \fBSOCK_NDELAY\fR,
 111 and takes precedence if both are set.  See \fBopen\fR(2) for further details.
 112 .RE
 113 
 114 .sp
 115 .ne 2
 116 .na
 117 \fB\fBSOCK_NONBLOCK\fR\fR
 118 .ad
 119 .RS 12n
 120 Creates the socket with the \fBO_NONBLOCK\fR flag set, causing the socket to
 121 provide nonblocking semantics as described for \fBO_NONBLOCK\fR in \fBopen\fR(2).
 122 .RE
 123 
 124 .sp
 125 .LP
 126 There must be an entry in the \fBnetconfig\fR(4) file for at least each
 127 protocol family and type required. If  a non-zero protocol has been specified
 128 but no exact match for the protocol family, type, and protocol is found, then
 129 the first entry containing the specified family and type with a \fIprotocol\fR
 130 value of zero will be used.
 131 .sp
 132 .LP
 133 A \fBSOCK_STREAM\fR type provides sequenced, reliable, two-way connection-based
 134 byte streams. An out-of-band data transmission mechanism may be supported. A
 135 \fBSOCK_DGRAM\fR socket supports datagrams (connectionless, unreliable messages
 136 of a fixed (typically small) maximum length). A \fBSOCK_SEQPACKET\fR socket may
 137 provide a sequenced, reliable, two-way connection-based data transmission path
 138 for datagrams of fixed maximum length; a consumer may be required to read an
 139 entire packet with each read system call. This facility is protocol specific,
 140 and presently not implemented for any protocol family. \fBSOCK_RAW\fR sockets
 141 provide access to internal network interfaces. The types \fBSOCK_RAW\fR, which
 142 is available only to a user with the \fBnet_rawaccess\fR privilege, and
 143 \fBSOCK_RDM\fR, for which no implementation currently exists, are not described
 144 here.


 269 .RE
 270 
 271 .sp
 272 .ne 2
 273 .na
 274 \fB\fBEPROTONOSUPPORT\fR\fR
 275 .ad
 276 .RS 19n
 277 The protocol type is not supported by the address family.
 278 .RE
 279 
 280 .sp
 281 .ne 2
 282 .na
 283 \fB\fBEPROTOTYPE\fR\fR
 284 .ad
 285 .RS 19n
 286 The socket type is not supported by the protocol.
 287 .RE
 288 
 289 .sp
 290 .ne 2
 291 .na
 292 \fB\fBEINVAL\fR\fR
 293 .ad
 294 .RS 19n
 295 One or more of the specified flags is not supported.
 296 .RE
 297 
 298 .SH ATTRIBUTES
 299 .sp
 300 .LP
 301 See \fBattributes\fR(5) for descriptions of the following attributes:
 302 .sp
 303 
 304 .sp
 305 .TS
 306 box;
 307 c | c
 308 l | l .
 309 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 310 _
 311 MT-Level        Safe
 312 .TE
 313 
 314 .SH SEE ALSO
 315 .sp
 316 .LP
 317 \fBnca\fR(1), \fBclose\fR(2), \fBfcntl\fR(2), \fBioctl\fR(2), \fBread\fR(2),