jptxs has asked for the wisdom of the Perl Monks concerning the following question:
then I have a little client I'm using to test it:my $socket = IO::Socket::INET->new( LocalPort => 1880, Type => SOCK_STREAM, Reuse => 1, Listen => 10 ) or die "Big Problem with the Server, Man : $!\n\n"; while ( $test ) { my $date = localtime(); warn "Started up: $date\n"; while ( my $client = $socket->accept() ) { my $message = <$client> ; warn "$message"; chomp $message; print $client 'Message recieved', "\n" if $message; if ( $message eq 'die' ) { #etc., etc. } } }
use IO::Socket::INET; my $socket; # for use in all scopes $socket = IO::Socket::INET->new( PeerAddr => 'localhost', PeerPort => '1880', Proto => "tcp", Type => SOCK_STREAM) or die "Big Problem connecting to Server, Man : $!\n\n"; while (1) { print 'talk to me, like keyboards do: '; my $input = ; chomp $input; if ( $input =~ /^q/i ) { exit; } else { print $socket "$input\n"; } }
"A man's maturity -- consists in having found again the seriousness one had as a child, at play." --Nietzsche
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: socket sending/getting one message then nothing
by chipmunk (Parson) on Apr 11, 2001 at 08:33 UTC | |
by jptxs (Curate) on Apr 11, 2001 at 21:27 UTC |