Tutorials Point


  Perl Home

  PERL Functions

© 2011 TutorialsPoint.COM


  Home     References     About TP     Advertising  

PERL getpeername Function



Syntax

getpeername SOCKET


Definition and Usage

Returns the packed socket address of the remote host attached to SOCKET.

Return Value

  • In scalar context undef on error otherwise packed socket address

Example

Usage Example: Here SOCK is the socket ID of the peer socket. This is the piece of program to use getpeername().
#!/usr/bin/perl

use Socket;

$hersockaddr    = getpeername(SOCK);
($port, $iaddr) = sockaddr_in($hersockaddr);
$herhostname    = gethostbyaddr($iaddr, AF_INET);
$herstraddr     = inet_ntoa($iaddr);



Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names