http://qs1969.pair.com?node_id=633233


in reply to A Simple Socket Server Using 'inetd'

Fantastic, very nice approach. Just one question. How can you find out the client's ip address / port using this approach?
  • Comment on Re: A Simple Socket Server Using 'inetd'

Replies are listed 'Best First'.
Re^2: A Simple Socket Server Using 'inetd'
by samizdat (Vicar) on Aug 21, 2007 at 13:15 UTC
    You can't, directly, of course. With netstat and arp you could figure it out, although the connection is transient.

    Don Wilde
    "There's more than one level to any answer."
      Hey guys, Is it possible to get a sample of your SECSII client? I'd like to make a SECSII communication over TCP but seems to be difficult to me... Thanks a lot!
        I was working for Sandia Labs at the time, and under NDA. Sorry!

        It isn't that difficult, actually. It's just a simple binary protocol like any other, though there are some quirky things to it. :D

        Don Wilde
        "There's more than one level to any answer."
      I am trying it out on Windows, set up inetd via Cygwin and start it as Windows service. It always prompt "Bad file descriptor". at: my $line = <STDIN> When I connect via "telnet localhost <port>". Would you please shed some lights on it? Thanks,
Re^2: A Simple Socket Server Using 'inetd'
by Sarten X (Initiate) on Oct 15, 2008 at 20:50 UTC
    You can, though I'm not sure if there's any quirks to it (including how it behaves when not run from inetd)
    my $hersockaddr = getpeername(STDOUT); my ($port, $iaddr) = sockaddr_in($hersockaddr); my $ip = inet_ntoa($iaddr);
    That gives you $port and $ip nicely ready to use.