Another option available to you is the use of Net::Server. Sample, untested code below. It only allows one connection at a time. If you need multiple simultanious client connections, check out the personalities offered by Net::Server (mainly Net::Server::Fork, Net::Server::PreFork, and Net::Server::PreForkSimple.
#!/usr/bin/perl -w package SimpleServer; use strict; use Net::Server; our @ISA = qw(Net::Server); SimpleServer->run( port => 2000, log_level => 4 ); exit; # The subroutine called when a new client connects sub process_request { my $self = shift; my $client = $self->{'server'}; while (1) { my $txt = <STDIN>; # STDIN and STDOUT are mapped to client $txt =~ s/\r?\n$//; print $txt, "\r\n"; } }
If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, reply to this node or /msg me to tell me what is wrong with the post, so that I may update the node to the best of my ability. If you do not inform me as to why the post deserved a downvote, your vote does not have any significance and will be disregarded.
In reply to Re: Sending and recieving data
by Coruscate
in thread Sending and recieving data
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |