[Chapter 3] 3.2.67 getsockname
Author: Larry Wall, Tom Christiansen & Randal L. Schwartz
Date: 1999-07-02T01:50:35Z

#

| Chapter 3 Functions |

### 3.2.67 getsockname

    getsockname SOCKET

This function returns the packed sockaddr address of this end of the `SOCKET` connection. (And why wouldn't you know your own address already? Because you might have bound an address containing wildcards to the generic socket before doing an accept. Or because you might have been passed a socket by your parent process - for example, inetd.)

    use Socket;
    $mysockaddr = getsockname(SOCK);
    ($port, $myaddr) = unpack_sockaddr_in($mysockaddr);

3.2.66 getservent |  | 3.2.68 getsockopt