1 '\" te 2 .\" Copyright 1989 AT&T Copyright (c) 1998, Sun Microsystems, Inc. All Rights Reserved 3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. 4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. 5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] 6 .TH GETPEERNAME 3SOCKET "Mar 26, 1998" 7 .SH NAME 8 getpeername \- get name of connected peer 9 .SH SYNOPSIS 10 .LP 11 .nf 12 \fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fB-lsocket\fR \fB -lnsl \fR [ \fIlibrary\fR ... ] 13 #include <sys/types.h> 14 #include <sys/socket.h> 15 16 \fBint\fR \fBgetpeername\fR(\fBint\fR \fIs\fR, \fBstruct sockaddr *\fR\fIname\fR, \fBsocklen_t *\fR\fInamelen\fR); 17 .fi 18 19 .SH DESCRIPTION 20 .LP 21 \fBgetpeername()\fR returns the name of the peer connected to socket \fIs\fR. 22 The \fBint\fR pointed to by the \fInamelen\fR parameter should be initialized 23 to indicate the amount of space pointed to by \fIname\fR. On return it contains 24 the actual size of the name returned (in bytes), prior to any truncation. The 25 name is truncated if the buffer provided is too small. 26 .SH RETURN VALUES 27 .LP 28 If successful, \fBgetpeername()\fR returns \fB0\fR; otherwise it returns 29 \fB\(mi1\fR and sets \fBerrno\fR to indicate the error. 30 .SH ERRORS 31 .LP 32 The call succeeds unless: 33 .sp 34 .ne 2 35 .na 36 \fB\fBEBADF\fR\fR 37 .ad 38 .RS 12n 39 The argument \fIs\fR is not a valid descriptor. 40 .RE 41 42 .sp 43 .ne 2 44 .na 45 \fB\fBENOMEM\fR\fR 46 .ad 47 .RS 12n 48 There was insufficient user memory for the operation to complete. 49 .RE 50 51 .sp 52 .ne 2 53 .na 54 \fB\fBENOSR\fR\fR 55 .ad 56 .RS 12n 57 There were insufficient STREAMS resources available for the operation to 58 complete. 59 .RE 60 61 .sp 62 .ne 2 63 .na 64 \fB\fBENOTCONN\fR\fR 65 .ad 66 .RS 12n 67 The socket is not connected. 68 .RE 69 70 .sp 71 .ne 2 72 .na 73 \fB\fBENOTSOCK\fR\fR 74 .ad 75 .RS 12n 76 The argument \fIs\fR is not a socket. 77 .RE 78 79 .SH ATTRIBUTES 80 .LP 81 See \fBattributes\fR(5) for descriptions of the following attributes: 82 .sp 83 84 .sp 85 .TS 86 box; 87 c | c 88 l | l . 89 ATTRIBUTE TYPE ATTRIBUTE VALUE 90 _ 91 MT-Level Safe 92 .TE 93 94 .SH SEE ALSO 95 .LP 96 \fBaccept\fR(3SOCKET), \fBbind\fR(3SOCKET), \fBgetsockname\fR(3SOCKET), 97 \fBsockaddr\fR(3SOCKET), 98 \fBsocket\fR(3SOCKET), \fBattributes\fR(5), \fBsocket.h\fR(3HEAD)