Perl Home
PERL Functions
© 2011 TutorialsPoint.COM
|
PERL getsockname Function
Syntax
Definition and Usage
Returns a packed address of the local end of the network socket SOCKET.
Return Value
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);
|
|

|
|
|