Two quickies first.
Now on to the meat.
TCP requires that a connection be made before high-level communication can begin. This requires the exchange packets (handshacking), and will fail if the peer is not listening for incoming connections on the specified port.
UDP, on the other hand, is a connection-less protocol. There is no handshacking during socket creation, so it's impossible to know if the other end is listening at that time.
Even sending a datagram to the peer is insufficient to detect if the peer is listening, because UDP is also an unreliable protocol. An unreliable protocol is one that doesn't notify its sender whether the data was sent successfully or not.
To ping a UDP port, it is necessary to send a datagram to the peer which provokes a response from the peer. I don't know of a generic way of doing this for UDP. As far as I know, it requires knowing how to communicate with the application using the UDP port. ( Now I do. See betterworld's reply )
Because UDP is unreliable, you need to try a few times in case the request or the response are lost in transit.
In reply to Re: UDP and IO::Socket::INET
by ikegami
in thread UDP and IO::Socket::INET
by tcf03
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |