On 6/26/06, netsql <[EMAIL PROTECTED]> wrote:
>
> I need to create a loop to send an ip ping to 500 addresses at time (and
> find out if ip conected or timedout to each)... and then repeat loop.
>
> Use ThreadPool and SOcketConnector? how to get started?


SocketConnector.connect() works asynchronously.  So you can initiate as many
connections as you want with in the range your O/S support.
SocketConnector.connect() allows you to specify a connect timeout value,
too.  Once called, it will return ConnectFuture object which will tell you
when the connection attempt is finished.

AFAIK, If you are trying to do ICMP ping( implemneted in JDK 1.5) this
approach -- SocketConnector.connect()  cannot be used. This is due to
Java implementation still does not give access to RAW sockets.

On the other hand, if you want to use TCP socket based ping ( Sun JDK
also uses this approach as the fail over case SUN JDK uses, if ICMP
ping is not available ), you can try Connecting TCP socket on target
host at 7(echo port ) and here are some possible error codes:
 * Connection Accepted/Refused-exception -- is host is up
 * Connection timedout -- Host most probably not up ( host might have
diabled the echo-port dues to some firewall rules,etc ). So if no
firewall rules are in internal LAN, a timedout connection definiltey
means a host is not up.


So you can use SocketConnector.connect() and ThreadPool to get that
functionality.


Hope this helps


mahadevan

Reply via email to