asynchronous sockets RRS feed

  • Question

  • Hi,
     I just want to discover the hosts active in network. My idea is try to 'connect', If succcessful thats enough for me. For that I made socket non blocking socket.( using iocltsocket and select with one second time out).

    For faster discovery, When I tried to use treads this fails . The sockets unable to establish connection(or initiate), When i increasd the time out few more hosts are discoverd.

    Is any issue with select when there a large number of threads doing same operation?

    Wednesday, August 1, 2007 1:20 PM

All replies




    Your goal of determining which hosts are active on a network is probably better served using a mechanism other than trying to connect to each host.  For example, if all the hosts are on the same subnet you can use WS-Discovery or your own multicast UDP multicast query/unicast response protocol to establish which hosts are listening.  Alternatively you might be able to query your DHCP servers to see which hosts have active DHCP leases if you aren't interested in which hosts are listening on a specific port.


    However, the hosts on the network you are scanning may have client firewalls which will drop unsolicited traffic.  If you can configure these client firewalls you could allow ICMP traffic and then just ping every host.  If you are not the network administrator and do not have permission to configure the client firewalls then I question why you are trying to scan the network for active hosts as this sort of behavior can easily be interpreted as malicious.

    Thursday, August 2, 2007 2:11 AM
  • Hi Eliot,
     Thanks for your reply.All hosts are not in the same subnet and in some host ICMP ping may be diasable. I am trying to connect only that hosts. And i am not bothered about the firewall ( If the host not allowing connection to my interested port i will conside it as dead).

    When i tired this using one thread it worked fine. it discoverd all hosts
    To reduse the time. I created one thread for each host. Then it giving inconsistant out put( discovered host is varying).

    I afraid that the windows is not able to handle too many non blocking connections parallel.

    So please comment this

    Thursday, August 2, 2007 7:33 AM