On 17 Apr 2008, at 12:58, Kr Alfabeta wrote:
> Thank you for all replays. Now everything is more clear. In php  
> manual:
>
> UDP sockets will sometimes appear to have opened without an error,  
> even
> if the remote host is unreachable. The error will only become apparent
> when you read or write data to/from the socket. The reason for this is
> because UDP is a "connectionless" protocol, which means that the
> operating system does not try to establish a link for the socket until
> it actually needs to send or receive data.

Typical.

This is wrong. "connectionless" needs no quotes, it *is*  
connectionless. The operating system never ever "establishes a link"  
with UDP. It merely constructs a UDP packet and passes it to the  
appropriate next-hop router (or the target ip if on the same subnet),  
and forgets about it. There is no link, there is no connection. With  
UDP there never will be. That's the point of the protocol.

> So in conclusion there is no way to check that UDP port is working or
> not? Maybe there is a common query which you can send by UDP and then
> receive any response?

No, you can check for a particular response *if* the application  
protocol is designed to send one, *or* you can be lucky and the target  
IP address will *actively refuse* the packet, in which case you get  
some notification back on some systems. This is not complete  
'checking' for a working application, *at all*. If the box goes  
completely offline, and there are no devices doing anything outside of  
the UDP protocol spec, then you'll get no notification of the failure  
to deliver. Nothing, nada, complete silence.

A timeout solution waiting for a response may be appropriate for  
*certain* application level protocols from which you might expect a  
response to your packets, however, this is really completely not the  
purpose of UDP.

Why are you trying to check that a UDP port is open? And if you need  
reliable communications you should be using TCP.

>
> -- 
> Posted via http://www.ruby-forum.com/.
>