use IO::Socket; #use the socket module use strict; #am bit careless so i need this my $socket=new IO::Socket::INET( LocalAddr=>'' , LocalPort=>8080, Listen=>1, ) or die "cannot create host\n"; my ($client,$scrap_out,$scrap_in); while($client=$socket->accept()) { while(1) { #now recieve the messeage $scrap_in=<$client>; print "scrap_in:\t$scrap_in\n"; print "scrap_out:\t"; $scrap_out=<>; print $client $scrap_out; if($scrap_out=~/'bye'/i or $scrap_in=~/'bye'/) {close $socket and die "connection closed\n";} } }