Start it off simple. I like to build the server and telnet into it to start with. Gives you full control of the client while getting the server figured out. The following works, though i think there are probably some major issues with it memory wise. It is a nice simple start though.
#!/usr/bin/perl use strict; use warnings; use threads; use IO::Socket; my $server = IO::Socket::INET->new(LocalPort => 1300, Proto => 'tcp', Listen => 10, Reuse => 1); die "Failed to create socket: $!\n" unless $server; my $client; sub listen_to_client { while (my $get = <$client>) { print "client: $get"; }; print "Client closed\n"; } while ($client = $server->accept()) { print "Client connected\n"; threads->create("listen_to_client"); }
I ran it in one terminal, then telnet-ed in from two separate windows. Works like a charm.
In reply to Re: chat between client and server
by eric256
in thread chat between client and server
by wavenator
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |