150 lines
4.5 KiB
HTML
150 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>getpeername</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
|
|
<basefont size="3"> <a name="getpeername"></a> <a name="tag_03_235"></a><!-- getpeername -->
|
|
<!--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_235_01"></a>NAME</h4>
|
|
|
|
<blockquote>getpeername - get the name of the peer socket</blockquote>
|
|
|
|
<h4><a name="tag_03_235_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 getpeername(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_235_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>getpeername</i>() function shall retrieve the peer address 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 protocol permits connections by unbound clients, and the peer is not bound, then the value stored in the object pointed
|
|
to by <i>address</i> is unspecified.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_235_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>Upon successful completion, 0 shall be returned. Otherwise, -1 shall be returned and <i>errno</i> set to indicate the error.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_235_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>getpeername</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>[EINVAL]</dt>
|
|
|
|
<dd>The socket has been shut down.</dd>
|
|
|
|
<dt>[ENOTCONN]</dt>
|
|
|
|
<dd>The socket is not connected or otherwise has not had the peer pre-specified.</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 the socket protocol.</dd>
|
|
</dl>
|
|
|
|
<p>The <i>getpeername</i>() function may fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[ENOBUFS]</dt>
|
|
|
|
<dd>Insufficient resources were available in the system to complete the call.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_235_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_235_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_235_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_235_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_235_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=
|
|
"getsockname.html"><i>getsockname</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_235_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>getpeername</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>
|
|
|