📄 getpeername.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>getpeername</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4>NAME</h4><blockquote>getpeername - get the name of the peer socket</blockquote><h4>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="syssocket.h.html">sys/socket.h</a>>int getpeername(int <I>socket</I>, struct sockaddr *<I>address</I>, socklen_t *<I>address_len</I>);</code></pre></blockquote><h4>DESCRIPTION</h4><blockquote>The<i>getpeername()</i>function retrieves the peer address of the specified socket, stores thisaddress in the <B>sockaddr</B> structure pointed to by the <I>address</I>argument, and stores the length of this address in the object pointed to bythe <I>address_len</I> argument.<p>If the actual length of the address is greater than the length of the supplied<B>sockaddr</B> structure, the stored address will be truncated.<p>If the protocol permits connections by unbound clients, and the peer is notbound, then the value stored in the object pointed to by <I>address</I> isunspecified.</blockquote><h4>RETURN VALUE</h4><blockquote>Upon successful completion, 0 is returned. Otherwise,-1 is returned and <I>errno</I> is set to indicate the error.</blockquote><h4>ERRORS</h4><blockquote>The<i>getpeername()</i>function will fail if:<dl compact><dt>[EBADF]<dd>The <I>socket</I> argument is not a valid file descriptor.<dt>[EFAULT]<dd>The <I>address</I>or <I>address_len</I>parameter can not be accessed or written.<dt>[EINVAL]<dd>The socket has been shut down.<dt>[ENOTCONN]<dd>The socket is not connected or otherwise has not had the peer prespecified.<dt>[ENOTSOCK]<dd>The <I>socket</I> argument does not refer to a socket.<dt>[EOPNOTSUPP]<dd>The operation is not supported for the socket protocol.</dl><p>The<i>getpeername()</i>function may fail if:<dl compact><dt>[ENOBUFS]<dd>Insufficient resources were available in the system to complete the call.<dt>[ENOSR]<dd>There were insufficient STREAMS resources available for the operation tocomplete.</dl></blockquote><h4>SEE ALSO</h4><blockquote><i><a href="accept.html">accept()</a></i>,<i><a href="bind.html">bind()</a></i>,<i><a href="getsockname.html">getsockname()</a></i>,<i><a href="socket.html">socket()</a></i>,<i><a href="syssocket.h.html"><sys/socket.h></a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -