in reply to Non-interactive Client/Server Using Sockets

This "problem" has been solved numerous times. Please consult CPAN.
  • Comment on Re: Non-interactive Client/Server Using Sockets

Replies are listed 'Best First'.
Re: Re: Non-interactive Client/Server Using Sockets
by BUU (Prior) on Sep 08, 2003 at 03:56 UTC
    my $server = new IO::Socket::INET(); while(my $client = $server->accept()) { next if fork; my $line = <$client>; print $client "You said: $line\m"; exit; }
    The server goes in to an infinte loop accepting new client connections, when it receives a connection it creates a new $client containg that connection and the forks. The parent goes back to waiting for the connection while the child reads a line from the client and prints one back to it. You could use various ->read() methods, but I find it much simpler to just read based on new lines.