On Thu, May 30, 2002 at 05:33:32AM -0400, Gerald Timothy Quimpo wrote:
> 
> i'm writing a little server that will run from xinetd.
> since xinetd servers read incoming data from stdin and
> write outgoing data to stdout, i don't see how to get
> the IP number of the remote host. one way to do that
> is to read the REMOTE_HOST environment variable.  i'm
> having confusing results with this though.
> 

Gerald (CC: ph-perl list),

How did you write the server? I mean, what language did you use? If it's
Perl then this sample code will help:

//--- Begin test.pl

#!/usr/bin/perl -wT
use strict;
use Socket;

my $peername = getpeername(STDIN);
my ($peerport, $peeraddr) = Socket::unpack_sockaddr_in($peername);
$peeraddr = inet_ntoa($peeraddr);

# $peeraddr is remote host's ip address
# $peerport is remote host's port

# place your code here

exit 0;

//--- End test.pl


It was tested using this xinetd config file:

//--- Begin /etc/xinetd.d/test

service test
{
        disable = no
        type            = UNLISTED
        flags           = REUSE
        port            = 5890
        socket_type     = stream
        protocol        = tcp
        wait            = no
        user            = nobody
        server          = /usr/local/bin/test.pl
}

//--- End /etc/xinetd.d/test


I hope this information help.
Best regards,
-- 
$_=q:; # SHERWIN #
70;72;69;6e;74;20;
27;4a;75;73;74;20;
61;6e;6f;74;68;65;
72;20;50;65;72;6c;
20;6e;6f;76;69;63;
65;27;:;;s=~?(..);
?=pack q$C$,hex$1;
;;;=egg;;;;eval;;;
_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]

To subscribe to the Linux Newbies' List: send "subscribe" in the body to 
[EMAIL PROTECTED]

Reply via email to