Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Ollie Cook
May 18, 2005, 7:42 pm
rate this thread
the IP address associated with each end of a socket. However, this
appears not to work for a script which is started from xinetd.
xinetd connects the socket over which the connection arrives to stdin
and stdout of the spawned process so when you read from standard input
you are in fact reading from the network.
In a C application started in this way, you can retrieve the IP
addresses associated with the 'socket' as follows (pseudocode only):
getpeername(fileno(stdin), (struct sockaddr *) &sa, &sz);
even though 'stdin' isn't a real socket.
However, doing a similar thing in Perl:
$sockaddr = getpeername(fileno(STDIN)); # 0
($port, $addr) = sockaddr_in($sockaddr);
gives the following error:
getpeername() on unopened socket 0 at proxy.pl line 258.
Use of uninitialized value in subroutine entry at
/usr/local/lib/perl5/5.6.1/mach/Socket.pm line 312.
Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be 16
at /usr/local/lib/perl5/5.6.1/mach/Socket.pm line 312.
Does anyone have any advice on how I might be able to get the IPs
associated with a socket, when that socket is in fact STDIN/STDOUT as
presented by xinetd? I am using Perl 5.6.1.
Any help would be greatly appreciated.
- » ssh on command line: force using a group size (prime size) of 1024 (and no...
- — The site's Newest Thread. Posted in » Secure Shell Forum