Web | This Site

Perl Home
PERL Functions
© 2011 TutorialsPoint.COM

| Home |  | References |  | About TP |  | Advertising

# PERL getsockname Function

## Syntax

getsockname SOCKET

## Definition and Usage

Returns a packed address of the local end of the network socket SOCKET.

## Return Value

- In scalar context undef on error otherwise Packed address of local socket

## Example

Try out following example: Here SOCK is the socket ID

    #!/usr/bin/perl

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

    printf "Connect to %s [%s]\n",
           scalar gethostbyaddr($myaddr, AF_INET),
           inet_ntoa($myaddr);

Advertisement

Online Image Processing

Indian Baby Names