add directory Ref-docs
This commit is contained in:
207
Ref-docs/POSIX/susv3/functions/socket.html
Normal file
207
Ref-docs/POSIX/susv3/functions/socket.html
Normal file
@@ -0,0 +1,207 @@
|
||||
<!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 The Open Group, All Rights Reserved -->
|
||||
<title>socket</title>
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<basefont size="3"> <a name="socket"></a> <a name="tag_03_708"></a><!-- socket -->
|
||||
<!--header start-->
|
||||
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
||||
IEEE Std 1003.1-2001<br>
|
||||
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
||||
|
||||
<!--header end-->
|
||||
<hr size="2" noshade>
|
||||
<h4><a name="tag_03_708_01"></a>NAME</h4>
|
||||
|
||||
<blockquote>socket - create an endpoint for communication</blockquote>
|
||||
|
||||
<h4><a name="tag_03_708_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 socket(int</tt> <i>domain</i><tt>, int</tt> <i>type</i><tt>, int</tt> <i>protocol</i><tt>);<br>
|
||||
</tt></code></p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_708_03"></a>DESCRIPTION</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>The <i>socket</i>() function shall create an unbound socket in a communications domain, and return a file descriptor that can be
|
||||
used in later function calls that operate on sockets.</p>
|
||||
|
||||
<p>The <i>socket</i>() function takes the following arguments:</p>
|
||||
|
||||
<dl compact>
|
||||
<dt><i>domain</i></dt>
|
||||
|
||||
<dd>Specifies the communications domain in which a socket is to be created.</dd>
|
||||
|
||||
<dt><i>type</i></dt>
|
||||
|
||||
<dd>Specifies the type of socket to be created.</dd>
|
||||
|
||||
<dt><i>protocol</i></dt>
|
||||
|
||||
<dd>Specifies a particular protocol to be used with the socket. Specifying a <i>protocol</i> of 0 causes <i>socket</i>() to use an
|
||||
unspecified default protocol appropriate for the requested socket type.</dd>
|
||||
</dl>
|
||||
|
||||
<p>The <i>domain</i> argument specifies the address family used in the communications domain. The address families supported by the
|
||||
system are implementation-defined.</p>
|
||||
|
||||
<p>Symbolic constants that can be used for the domain argument are defined in the <a href=
|
||||
"../basedefs/sys/socket.h.html"><i><sys/socket.h></i></a> header.</p>
|
||||
|
||||
<p>The <i>type</i> argument specifies the socket type, which determines the semantics of communication over the socket. The
|
||||
following 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 for
|
||||
out-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 or
|
||||
more output operations and received using one or more input operations, but a single operation never transfers part of more than
|
||||
one 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 by
|
||||
the system are implementation-defined.</p>
|
||||
|
||||
<p>The process may need to have appropriate privileges to use the <i>socket</i>() function or to create some sockets.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_708_04"></a>RETURN VALUE</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>Upon successful completion, <i>socket</i>() shall return a non-negative integer, the socket file descriptor. Otherwise, a value
|
||||
of -1 shall be returned and <i>errno</i> set to indicate the error.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_708_05"></a>ERRORS</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>The <i>socket</i>() function shall fail if:</p>
|
||||
|
||||
<dl compact>
|
||||
<dt>[EAFNOSUPPORT]</dt>
|
||||
|
||||
<dd><br>
|
||||
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>[EPROTONOSUPPORT]</dt>
|
||||
|
||||
<dd><br>
|
||||
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>socket</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_708_06"></a>EXAMPLES</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>None.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_708_07"></a>APPLICATION USAGE</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>The documentation for specific address families specifies which protocols each address family supports. The documentation for
|
||||
specific protocols specifies which socket types each protocol supports.</p>
|
||||
|
||||
<p>The application can determine whether an address family is supported by trying to create a socket with <i>domain</i> set to the
|
||||
protocol in question.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_708_08"></a>RATIONALE</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>None.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_708_09"></a>FUTURE DIRECTIONS</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>None.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_708_10"></a>SEE ALSO</h4>
|
||||
|
||||
<blockquote>
|
||||
<p><a href="accept.html"><i>accept</i>()</a> , <a href="bind.html"><i>bind</i>()</a> , <a href="connect.html"><i>connect</i>()</a>
|
||||
, <a href="getsockname.html"><i>getsockname</i>()</a> , <a href="getsockopt.html"><i>getsockopt</i>()</a> , <a href=
|
||||
"listen.html"><i>listen</i>()</a> , <a href="recv.html"><i>recv</i>()</a> , <a href="recvfrom.html"><i>recvfrom</i>()</a> , <a
|
||||
href="recvmsg.html"><i>recvmsg</i>()</a> , <a href="send.html"><i>send</i>()</a> , <a href="sendmsg.html"><i>sendmsg</i>()</a> , <a
|
||||
href="setsockopt.html"><i>setsockopt</i>()</a> , <a href="shutdown.html"><i>shutdown</i>()</a> , <a href=
|
||||
"socketpair.html"><i>socketpair</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
||||
"../basedefs/netinet/in.h.html"><i><netinet/in.h></i></a>, <a href=
|
||||
"../basedefs/sys/socket.h.html"><i><sys/socket.h></i></a></p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_708_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>
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user