#!/usr/bin/perl -w use warnings; use strict; use threads; use IO::Socket; my $so = new IO::Socket::INET(LocalPort => '1300', Proto => 'tcp', Listen => 10, Reuse => 1,); my $client; die "Socket Error: $!\n" unless $so; sub start_thread1 { print "thread1 started\n"; while(my $get=<$client>) { print "client : $get"; } print "thread1 ended\n"; } sub start_thread { print "thread started\n"; print $client "OK ... whaddaya want?\n"; while (my $msg = ) { print $client $msg; } print "thread ended\n"; } while ($client = $so->accept()) { my $thread = threads->create("start_thread"); my $thread1 = threads->create("start_thread1"); # This message appears to go nowhere ... we should use $client! print $so "connected ... whatcha want?\n"; print "connected\n"; $thread->join(); }