Hi. I'm using IO::socket::INET to act as a client to connect to a chat server. My Problem is that when i'm waiting to get data from the socket, I can't do anyting else (like sending keep-alive message every two minutes to keep from getting disconnected!). Here is a piece of code to illistrate what i'm saying...
while (1)
{
$MySocket->recv($text,256);
if (($currenttime + 120) <= time()) # Used for keep-alive.
{
$currenttime = time();
$MySocket->send("Jp\n");
print "Ping?\n";
}
}
THe Conditional isn't reached until the socket receives data, which means that if the socket never receives data, nothing happens! Can anyone help?
while (1)
{
$MySocket->recv($text,256);
if (($currenttime + 120) <= time()) # Used for keep-alive.
{
$currenttime = time();
$MySocket->send("Jp\n");
print "Ping?\n";
}
}
THe Conditional isn't reached until the socket receives data, which means that if the socket never receives data, nothing happens! Can anyone help?