in reply to Re: Re: Distributing Perl GUI Clients for Server Apps
in thread Distributing Perl GUI Clients for Server Apps
IO::Socket is the OO version of the basic 'Socket' module - you can use either, though it's usually easier to use the first to do something like below...
A client...
A server...use IO::Socket::INET; my $socket = IO::Socket::INET->new("${my_server}:${my_port}") or die $ +!; print $socket "My Ping\n"; my $answer = <$socket>; #should be 'My Pong' close $socket;
...which is obviously not going anywhere near production code, but should be enough to get started with. Check out the 'Sockets' section of the Camel Book for more info.use IO::Socket::INET; my $server = IO::Socket::INET->new(LocalPort=>$my_port,Type=>SOCK_STRE +AM,Listen=>1) or die $!; while (my $client = $server->accept()) { my $message = <$client>; print $client "My Pong\n" if ($message =~/My Ping/); }
Cheers, Ben.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Distributing Perl GUI Clients for Server Apps
by Anonymous Monk on Aug 06, 2003 at 17:35 UTC |