Hi all
To see if a port is listening on a Unix Server command is :
netstat -an | grep port number | grep LISTEN
To see what process is using a port the command is :
lsof -i tcp:port number
Here a simple perl programm to open a port and check a connection from a client web :
#!/usr/bin/perl -w
use IO::Socket;
use Net::hostent; # for OO version of gethostbyaddr
$PORT = 8080;
$server = IO::Socket::INET->new( Proto => 'tcp',
LocalPort => $PORT,
Listen => 5,
Reuse => 1) or die "can't setup server" unless $server;
printf("\nSERVER Waiting for client connection on port $PORT");
while ($client = $server->accept()) {
printf("\nClient Connected\n");
$client->autoflush(1);
print $client "
close $client;
}
Stay tuned
Nessun commento:
Posta un commento