148 lines
4.5 KiB
HTML
148 lines
4.5 KiB
HTML
<!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>getsockname</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
|
|
<basefont size="3"> <a name="getsockname"></a> <a name="tag_03_251"></a><!-- getsockname -->
|
|
<!--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_251_01"></a>NAME</h4>
|
|
|
|
<blockquote>getsockname - get the socket name</blockquote>
|
|
|
|
<h4><a name="tag_03_251_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 getsockname(int</tt> <i>socket</i><tt>, struct sockaddr *restrict</tt> <i>address</i><tt>,<br>
|
|
socklen_t *restrict</tt> <i>address_len</i><tt>);<br>
|
|
</tt></code></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_251_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>getsockname</i>() function shall retrieve the locally-bound name of the specified socket, store this address in the
|
|
<b>sockaddr</b> structure pointed to by the <i>address</i> argument, and store the length of this address in the object pointed to
|
|
by the <i>address_len</i> argument.</p>
|
|
|
|
<p>If the actual length of the address is greater than the length of the supplied <b>sockaddr</b> structure, the stored address
|
|
shall be truncated.</p>
|
|
|
|
<p>If the socket has not been bound to a local name, the value stored in the object pointed to by <i>address</i> is
|
|
unspecified.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_251_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>Upon successful completion, 0 shall be returned, the <i>address</i> argument shall point to the address of the socket, and the
|
|
<i>address_len</i> argument shall point to the length of the address. Otherwise, -1 shall be returned and <i>errno</i> set to
|
|
indicate the error.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_251_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>getsockname</i>() function shall fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[EBADF]</dt>
|
|
|
|
<dd>The <i>socket</i> argument is not a valid file descriptor.</dd>
|
|
|
|
<dt>[ENOTSOCK]</dt>
|
|
|
|
<dd>The <i>socket</i> argument does not refer to a socket.</dd>
|
|
|
|
<dt>[EOPNOTSUPP]</dt>
|
|
|
|
<dd>The operation is not supported for this socket's protocol.</dd>
|
|
</dl>
|
|
|
|
<p>The <i>getsockname</i>() function may fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[EINVAL]</dt>
|
|
|
|
<dd>The socket has been shut down.</dd>
|
|
|
|
<dt>[ENOBUFS]</dt>
|
|
|
|
<dd>Insufficient resources were available in the system to complete the function.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_251_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_251_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_251_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_251_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_251_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=
|
|
"getpeername.html"><i>getpeername</i>()</a> , <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_251_11"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 6. Derived from the XNS, Issue 5.2 specification.</p>
|
|
|
|
<p>The <b>restrict</b> keyword is added to the <i>getsockname</i>() prototype for alignment with the ISO/IEC 9899:1999
|
|
standard.</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>
|
|
|