I am writing a script to send a 40 byte header to the server, then the server will respond with 40 bytes of data which I will parse.
This data will be sent to me every 1 second. This is what I have so far:
#Connect to socket
#Send 40 bytes of data to the server
my $sock = IO::Socket::INET->new(Proto => 'tcp',
Type => SOCK_STREAM);
my $addr = sockaddr_in($port,inet_aton($host));
my $result = $sock->connect($addr);
#while loop - to get request from server (which will be sent every second)
#Get data from server
print $socket $db
#Parse this data - store into a file.
I want the connection to remain active even if there is no data passed to the client.
I already have the code to write it to a file. I guess I am unsure as far as how to keep the connection active...