Hi:
> I have a question. As we know, scanning TCP ports is a lot eaiser
than UDP
> ports because active UDP ports don't respond and there are other
reasons as
> well.
>
> try{
> Socket soc= new Scoket(address, portnumber);
>
> }
>
> catch(Throwable e){ System.out.println(e)}
>
> look at the code above, it can only tell you active TCP ports for the
> Throwable e tells you nothing about UDP ports. An active UDP port
doesn'
> respond to the connection call "soc". Therefore it will throw an
> exception(connection refused) after trying to connect an active UDP
port.
> This exception is just like those of closed TCP ports.
>
> What i am saying is that active UDP ports will be treated the same as
closed
> TCP ports. They are hidden in closed TCP ports. How do i sift them
out? Any
> solutions?
Gordon Beaton - 22 Apr 2006 08:26 GMT
> Socket soc= new Scoket(address, portnumber);
> look at the code above, it can only tell you active TCP ports for
> the Throwable e tells you nothing about UDP ports. An active UDP
[quoted text clipped - 3 lines]
>
> This exception is just like those of closed TCP ports.
The Socket class is TCP only and has absolutely no relevance to UDP.
Similarly, TCP and UDP ports have nothing to do with each other.
If the Socket constructor throws an exception, it's because it failed
to connect to the specified TCP port. It says nothing about whether
the corresponding UDP port is active or not.
Instead you need to create and connect() a DatagramSocket, then
attempt to send() a datagram. Note that with UDP, connected only means
that the DatagramSocket is (locally) associated with a specific remote
address. Unlink TCP, no connection is actually established, so you
need to actually send a datagram to determine whether the remote is
active.
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e