I need to detect but not interfere with a network port.
In short I want a script that listens on port 2000 in tandem with another application. This script will trigger a batch file when the port is active. What is happening now is when this script runs it blocks the other app. Any wisdom is welcome.
My current attempt:use warnings; # use strict; use IO::Socket; use Socket; my $port = shift || 2000; my $socket = IO::Socket::INET->new( LocalPort => $port, Type => SOCK_STREAM, Reuse => 1, Listen => 10, ) or die "Couldn't create server: $@\n"; while (my $client = $socket->accept()) { my ($port, $iaddr) = unpack_sockaddr_in($client->peername()); #### GET TIME #### $t = time(); my $then = localtime($t); #### GET IP #### my $ip_address = inet_ntoa($iaddr); open(PLOT,">>label-log.txt") || die("This file will not open!"); seek PLOT,0,2; print PLOT "$ip_address $then \n"; close(PLOT); sleep(5); system ("start /b C:\\momlabels\\transfer.bat"); $client->send(inet_ntoa($iaddr)); $client->close(); }
In reply to Networking with IO::Socket by TheVend
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |