Perl getpeername Function
Description
This function returns the packed socket address of the remote host attached to SOCKET.
Syntax
Following is the simple syntax for this function −
getpeername SOCKET
Return Value
This function returns undef on error otherwise packed socket address in scalar context.
Example
Following is the example code showing its basic usage, here SOCK is the socket ID of the peer socket −
#!/usr/bin/perl use Socket; $hersockaddr = getpeername(SOCK); ($port, $iaddr) = sockaddr_in($hersockaddr); $herhostname = gethostbyaddr($iaddr, AF_INET); $herstraddr = inet_ntoa($iaddr);
perl_function_references.htm
Advertisements