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";} } } #### use IO::Socket; use strict; print "enter host name to connect to:\t"; my $hostname=<>; my $socket= new IO::Socket::INET( PeerAddr=>$hostname, PeerPort=>8080, Reuse=>1, ) or die "cannot connect to host at this time\n"; my($scrap_in,$scrap_out); while(1) { print "scrap_out:\t"; $scrap_out=<>; print $socket $scrap_out; $scrap_in=<$socket>; print "scrap_in:\t$scrap_in\n"; if($scrap_in=~/'bye'/i or $scrap_out=~/'bye'/i) {close $socket and die "connection ended\n";} }