So, I'm wondering if this is the right approach. I think the core of the problem is that I'm waiting for incoming data to determine if a connection has been established.my $hSocket = IO::Socket::INET->new( LocalPort=>$intListenPort, Proto=>$strProtocol ) or die "Can't create UDP socket: $@"; ioctl($hSocket, 0x8004667e, pack("I", 1)); my ($datagram,$flags); # Wait for a datagram, then open a response port, respond, then close both ports. while ($hSocket->recv($datagram,42,$flags)) { ...
Is there another way to watch for client connection (and corresponding technique to time-out), before establishing the recv loop? For instance, doesn't IO::Socket call an accept method on connection? So couldn't I check $hSocket for a value (undef?) until timeout, and then launch the recv loop once I have a client? Or maybe using the accept method directly, like
until ($hSocket->accept()) { ...check for timeout ...close socket and exit if timeout } while ($hSocket->recv($datagram,42,$flags)) { ...
I guess I'm asking if blocking is really the problem or my approach to checking for connection. I think...
In reply to Re^2: Timeout Socket recv on UDP... on windows
by shunyun
in thread Timeout Socket recv on UDP... on windows
by shunyun
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |