in reply to IO::Socket::INET issues?

This works with TCP because IO::Socket::INET->new() calls connect() in that case which does a SYN/ACK handshake to open a connection. The handshake fails if the port is not open.

UDP is a connectionless protocol so nothing happens on the network until you try to send some packets to the peer. Creating the socket will succeed whether the remote port is open or not.

Replies are listed 'Best First'.
Re^2: IO::Socket::INET issues?
by Anonymous Monk on Jul 17, 2004 at 02:02 UTC
    So what would be a valid check for an open UDP port? I cannot see an option or function in the module that would allow for this test.

      The question is a bit vague. What are you try to check?

      • If you want to know whether the UDP socket is created successfully, then check the return code from new() is good enough. If it succeeds, it means that a local port has been picked, and a UDP socket is created.
      • If you want to check whether you can actually send packet, then send a packet, and see whether the peer receives it. If you want to see whether, it can receive, then let the peer send something.

      No magic here. By the way, UDP does not gurantee successful delivery, so even the packet is not received on either side, does not neccessarily to indicate a problem in your code.