Maybe I'm just going about sending data back in the wrong way? I'm unsure of how to get the handle to send from the 'server' to the 'client'. Here's the socket portion of what I have so far:
'Server'
my $clientSocket = new IO::Socket::INET(
PeerAddr => $ipSend,
PeerPort => $sendPort,
Proto => 'tcp',
);
$clientSocket or die "Could not create socket:$!\n";
print $clientSocket "HELLO 1.0";
sleep(3);
close $clientSocket;
'Client'
my $servSocket = IO::Socket::INET->new(
#LocalHost => 'localhost',
LocalPort => $listenPort, #7890
Proto => 'tcp',
Listen => 2,
Reuse => 1
);
$servSocket or die "Could not create socket:$!\n";
my($tempSocket, $clientAddr, $buffer);
while (($tempSocket, $clientAddr) = $servSocket->accept()) {
my ($clientPort, $clientIP) = sockaddr_in($clientAddr);
my $clientIPNum = inet_ntoa($clientIP);
my $clientHost = gethostbyaddr($clientIP, AF_INET);
while (defined ($buffer = <$tempSocket>)) {
print $buffer;
if ($buffer =~ m/^HELLO (\d+.\d+)/) {
my $version = $1;
if ($version == "1.0") {
#This doesn't work
#Want to send "HELLO 1.0" back through the socke
+t
#Is the $tempSocket handle just wrong, or
#can I not use print to do this?
print $tempSocket "HELLO 1.0";
}
}
last;
}
}