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) 1997, Sun Microsystems, Inc. All Rights Reserved 20 .\" Copyright 2018 Nexenta Systems, Inc. 21 .\" 22 .Dd August 2, 2018 23 .Dt GETSOCKNAME 3C 24 .Os 25 .Sh NAME 26 .Nm getsockname 27 .Nd get socket name 28 .Sh LIBRARY 29 .Lb libc 30 .Sh SYNOPSIS 31 .In sys/types.h 32 .In sys/socket.h 33 .Ft int 34 .Fo getsockname 35 .Fa "int s" 36 .Fa "struct sockaddr *restrict name" 37 .Fa "socklen_t *namelen" 38 .Fc 39 .Sh DESCRIPTION 40 .Fn getsockname 41 returns the current 42 .Fa name 43 for socket 44 .Fa s . 45 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 in bytes of the name returned. 50 .Sh RETURN VALUES 51 If successful, 52 .Fn getsockname 53 returns 0; otherwise it returns -1 and sets 54 .Va errno 55 to indicate the error. 56 .Sh ERRORS 57 The call succeeds unless: 58 .Bl -tag -width Er 59 .It Bq Er EBADF 60 The argument 61 .Fa s 62 is not a valid file descriptor. 63 .It Bq Er ENOMEM 64 There was insufficient memory available for the operation to complete. 65 .It Bq Er ENOSR 66 There were insufficient STREAMS resources available for the operation to 67 complete. 68 .It Bq Er ENOTSOCK 69 The argument 70 .Fa s 71 is not a socket. 72 .El 73 .Sh MT-LEVEL 74 .Sy Safe 75 .Sh SEE ALSO 76 .Xr bind 3C , 77 .Xr getpeername 3C , 78 .Xr sockaddr 3C , 79 .Xr socket 3C , 80 .Xr attributes 5