1 .\" 2 .\" The contents of this file are subject to the terms of the 3 .\" Common Development and Distribution License (the "License"). 4 .\" You may not use this file except in compliance with the License. 5 .\" 6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 7 .\" or http://www.opensolaris.org/os/licensing. 8 .\" See the License for the specific language governing permissions 9 .\" and limitations under the License. 10 .\" 11 .\" When distributing Covered Code, include this CDDL HEADER in each 12 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. 13 .\" If applicable, add the following below this CDDL HEADER, with the 14 .\" fields enclosed by brackets "[]" replaced with your own identifying 15 .\" information: Portions Copyright [yyyy] [name of copyright owner] 16 .\" 17 .\" 18 .\" Copyright 1989 AT&T 19 .\" Copyright (c) 1998, Sun Microsystems, Inc. All Rights Reserved 20 .\" Copyright 2018 Nexenta Systems, Inc. 21 .\" 22 .Dd August 2, 2018 23 .Dt GETPEERNAME 3C 24 .Os 25 .Sh NAME 26 .Nm getpeername 27 .Nd get name of connected peer 28 .Sh LIBRARY 29 .Lb libc 30 .Sh SYNOPSIS 31 .In sys/types.h 32 .In sys/socket.h 33 .Ft int 34 .Fo getpeername 35 .Fa "int s" 36 .Fa "struct sockaddr *restrict name" 37 .Fa "socklen_t *namelen" 38 .Fc 39 .Sh DESCRIPTION 40 .Fn getpeername 41 returns the name of the peer connected to socket 42 .Fa s . 43 The 44 .Vt int 45 pointed to by the 46 .Fa namelen 47 parameter should be initialized to indicate the amount of space pointed to by 48 .Fa name . 49 On return it contains the actual size of the name returned (in bytes), prior to 50 any truncation. 51 The name is truncated if the buffer provided is too small. 52 .Sh RETURN VALUES 53 If successful, 54 .Fn getpeername 55 returns 0; otherwise it returns -1 and sets 56 .Va errno 57 to indicate the error. 58 .Sh ERRORS 59 The call succeeds unless: 60 .Bl -tag -width Er 61 .It Bq Er EBADF 62 The argument 63 .Fa s 64 is not a valid descriptor. 65 .It Bq Er ENOMEM 66 There was insufficient user memory for the operation to complete. 67 .It Bq Er ENOSR 68 There were insufficient STREAMS resources available for the operation to 69 complete. 70 .It Bq Er ENOTCONN 71 The socket is not connected. 72 .It Bq Er ENOTSOCK 73 The argument 74 .Fa s 75 is not a socket. 76 .El 77 .Sh MT-LEVEL 78 .Sy Safe 79 .Sh SEE ALSO 80 .Xr accept 3C , 81 .Xr bind 3C , 82 .Xr getsockname 3C , 83 .Xr sockaddr 3C , 84 .Xr socket 3C , 85 .Xr socket.h 3HEAD , 86 .Xr attributes 5