.\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" %sccs.include.redist.man% .\" .\" @(#)getsockname.2 8.1 (Berkeley) 06/04/93 .\" .Dd .Dt GETSOCKNAME 2 .Os BSD 4.2 .Sh NAME .Nm getsockname .Nd get socket name .Sh SYNOPSIS .Ft int .Fn getsockname "int s" "struct sockaddr *name" "int *namelen" .Sh DESCRIPTION .Fn Getsockname returns the current .Fa name for the specified socket. The .Fa namelen parameter should be initialized to indicate the amount of space pointed to by .Fa name . On return it contains the actual size of the name returned (in bytes). .Sh DIAGNOSTICS A 0 is returned if the call succeeds, -1 if it fails. .Sh ERRORS The call succeeds unless: .Bl -tag -width ENOTSOCKAA .It Bq Er EBADF The argument .Fa s is not a valid descriptor. .It Bq Er ENOTSOCK The argument .Fa s is a file, not a socket. .It Bq Er ENOBUFS Insufficient resources were available in the system to perform the operation. .It Bq Er EFAULT The .Fa name parameter points to memory not in a valid part of the process address space. .El .Sh SEE ALSO .Xr bind 2 , .Xr socket 2 .Sh BUGS Names bound to sockets in the UNIX domain are inaccessible; .Xr getsockname returns a zero length name. .Sh HISTORY The .Nm function call appeared in .Bx 4.2 .