#!/usr/bin/perl -w use strict; use IO::Socket; my $socket = IO::Socket::INET->new('LocalPort' => 7890, 'Proto' => 'tcp', 'Listen' => SOMAXCONN) or die "Can't create socket ($!)\n"; print "[Server Started]\n"; while (my $client = $socket->accept) { if ($client->peeraddr) { print "[Connect from " . gethostbyaddr($client->peeraddr, AF_INET) . "]\n"; } my $reply = "test"; my $act = <$client>; print $act; print $client "$reply\n"; close $client or die "Can't close ($!)\n"; } die "Can't accept socket ($!)\n"; #### #!/usr/bin/perl -w use strict; use IO::Socket; my $host = shift || die "No host"; my $port = 7890; my $action = shift || die "No action"; my $ip = shift || die "No ip"; my $sock = new IO::Socket::INET( PeerAddr => $host, PeerPort => $port, Proto => 'tcp') or die "Can't Bind :$@!\n\n"; print $sock "$action "; print $sock "$ip\n"; while( <$sock> ) { print $_; } close $sock;