socketpair.html
来自「posix标准英文,html格式」· HTML 代码 · 共 205 行
HTML
205 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2004 IEEE and The Open Group, All Rights Reserved --><title>socketpair</title></head><body bgcolor="white"><basefont size="3"> <a name="socketpair"></a> <a name="tag_03_709"></a><!-- socketpair --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2004 Edition<br>Copyright © 2001-2004 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_709_01"></a>NAME</h4><blockquote>socketpair - create a pair of connected sockets</blockquote><h4><a name="tag_03_709_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>#include <<a href="../basedefs/sys/socket.h.html">sys/socket.h</a>><br><br> int socketpair(int</tt> <i>domain</i><tt>, int</tt> <i>type</i><tt>, int</tt> <i>protocol</i><tt>,<br> int</tt> <i>socket_vector</i><tt>[2]);<br></tt></code></p></blockquote><h4><a name="tag_03_709_03"></a>DESCRIPTION</h4><blockquote><p>The <i>socketpair</i>() function shall create an unbound pair of connected sockets in a specified <i>domain</i>, of a specified<i>type</i>, under the protocol optionally specified by the <i>protocol</i> argument. The two sockets shall be identical. The filedescriptors used in referencing the created sockets shall be returned in <i>socket_vector</i>[0] and <i>socket_vector</i>[1].</p><p>The <i>socketpair</i>() function takes the following arguments:</p><dl compact><dt><i>domain</i></dt><dd>Specifies the communications domain in which the sockets are to be created.</dd><dt><i>type</i></dt><dd>Specifies the type of sockets to be created.</dd><dt><i>protocol</i></dt><dd>Specifies a particular protocol to be used with the sockets. Specifying a <i>protocol</i> of 0 causes <i>socketpair</i>() touse an unspecified default protocol appropriate for the requested socket type.</dd><dt><i>socket_vector</i></dt><dd>Specifies a 2-integer array to hold the file descriptors of the created socket pair.</dd></dl><p>The <i>type</i> argument specifies the socket type, which determines the semantics of communications over the socket. Thefollowing socket types are defined; implementations may specify additional socket types:</p><dl compact><dt>SOCK_STREAM</dt><dd>Provides sequenced, reliable, bidirectional, connection-mode byte streams, and may provide a transmission mechanism forout-of-band data.</dd><dt>SOCK_DGRAM</dt><dd>Provides datagrams, which are connectionless-mode, unreliable messages of fixed maximum length.</dd><dt>SOCK_SEQPACKET</dt><dd>Provides sequenced, reliable, bidirectional, connection-mode transmission paths for records. A record can be sent using one ormore output operations and received using one or more input operations, but a single operation never transfers part of more thanone record. Record boundaries are visible to the receiver via the MSG_EOR flag.</dd></dl><p>If the <i>protocol</i> argument is non-zero, it shall specify a protocol that is supported by the address family. If the<i>protocol</i> argument is zero, the default protocol for this address family and type shall be used. The protocols supported bythe system are implementation-defined.</p><p>The process may need to have appropriate privileges to use the <i>socketpair</i>() function or to create some sockets.</p></blockquote><h4><a name="tag_03_709_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, this function shall return 0; otherwise, -1 shall be returned and <i>errno</i> set to indicate theerror.</p></blockquote><h4><a name="tag_03_709_05"></a>ERRORS</h4><blockquote><p>The <i>socketpair</i>() function shall fail if:</p><dl compact><dt>[EAFNOSUPPORT]</dt><dd>The implementation does not support the specified address family.</dd><dt>[EMFILE]</dt><dd>No more file descriptors are available for this process.</dd><dt>[ENFILE]</dt><dd>No more file descriptors are available for the system.</dd><dt>[EOPNOTSUPP]</dt><dd>The specified protocol does not permit creation of socket pairs.</dd><dt>[EPROTONOSUPPORT]</dt><dd>The protocol is not supported by the address family, or the protocol is not supported by the implementation.</dd><dt>[EPROTOTYPE]</dt><dd>The socket type is not supported by the protocol.</dd></dl><p>The <i>socketpair</i>() function may fail if:</p><dl compact><dt>[EACCES]</dt><dd>The process does not have appropriate privileges.</dd><dt>[ENOBUFS]</dt><dd>Insufficient resources were available in the system to perform the operation.</dd><dt>[ENOMEM]</dt><dd>Insufficient memory was available to fulfill the request.</dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_709_06"></a>EXAMPLES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_709_07"></a>APPLICATION USAGE</h4><blockquote><p>The documentation for specific address families specifies which protocols each address family supports. The documentation forspecific protocols specifies which socket types each protocol supports.</p><p>The <i>socketpair</i>() function is used primarily with UNIX domain sockets and need not be supported for other domains.</p></blockquote><h4><a name="tag_03_709_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_709_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_709_10"></a>SEE ALSO</h4><blockquote><p><a href="socket.html"><i>socket</i>()</a>, the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/sys/socket.h.html"><i><sys/socket.h></i></a></p></blockquote><h4><a name="tag_03_709_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 6. Derived from the XNS, Issue 5.2 specification.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?