in reply to Help writing to socket using IO::Select
G'day rdbunch,
Welcome to the monastery.
The "Perl Interprocess Communication" document should have most of what you need (or provide links to other relevant documentation).
Within that document, "TCP Servers with IO::Socket" is possibly your best starting point. It contains an example with the server getting commands from the client, processing those commands, and returning appropriate feedback: this seems very similar to your functionality.
As a side note, I'd suggest changing your list of if statements:
if ($cmd =~ /.../) { ... } if ($cmd =~ /.../) { ... } if ($cmd =~ /.../) { ... }
to be something more like this:
if ($cmd =~ /.../) { ... } elsif ($cmd =~ /.../) { ... } elsif ($cmd =~ /.../) { ... } else { warn "$cmd unrecognised!"; }
That will save unnecessary conditional processing and also provides an alert for unknown commands.
-- Ken
|
|---|