Operating System - HP-UX
1748179 Members
3839 Online
108758 Solutions
New Discussion юеВ

Re: Checking connection to UDP ports

 
SOLVED
Go to solution
lawrenzo_1
Super Advisor

Checking connection to UDP ports

Hi all,

does anyone know a way I can test connectivity to a UDP port across the network? It's easy with TCP but not sure how to do it with UDP - is there a script I can use?

Many Thanks

Chris
hello
2 REPLIES 2
rick jones
Honored Contributor
Solution

Re: Checking connection to UDP ports

"It depends" - indeed for TCP you can just try to connect, and if connect() succeeds you can presume there is something there. UDP you would have to know the application-level protocol spoken by any application which might be bound to that port.

If you go the "send a message" route, you should probably send a zero-length message (UDP allows it) to minimize (but not eliminate) the possiblity of doing something unpleasant to the remote. You should not, however, expect any response.

In theory, if there is nothing bound to the UDP port, the remote system will respond with an ICMP Destination Unreachable message with a suitable subcode. If you have called bind() on your UDP socket, and IIRC perhaps issue an ioctl or two, it may (stretching my memory) be possible to get the ICMP message passed-up to your application. At the very least, a subsequent socket call - perhaps a getsockopt() to check socket error will return an error of some sort.

Of course, since there is no "reliability" in UDP, you have to deal with the very real possiblity that either your UDP datagram or the resulting ICMP message are lost...
there is no rest for the wicked yet the virtuous have no pillows
lawrenzo_1
Super Advisor

Re: Checking connection to UDP ports

Thanks Rick,

I will do some research around your comments.

Chris
hello