windows - Python, Getting All LAN IPs -


i trying print live ips connected network in fastest way. tried ping in loop, slow:

def pingtry(host):     ping = subprocess.popen(["ping", host], stdout = subprocess.pipe, stderr = subprocess.pipe)     out, error = ping.communicate()     print out #this show me ping result, can check content , see if host replyed or not 

as said, slow (i need 255 times).

i tried connect using tcp connection port 80:

import socket ip = '192.168.1.100' port = 80 tcpsoc = socket(af_inet, sock_stream) tcpsoc.listen(somaxconn) try:     tcpsoc.bind(addr) except exception,ex:     print "host down!" 

but still, doesn't work ip, although working router ip

is there way getting live ips faster?

ping appropriate way ask machine if has claimed ip address. slow because (depending on platform) ping timeout second. can speed reducing timeout or using threading module send multiple pings @ same time.

you implement ping in python directly: pinging servers in python

alternatively, use tool nmap.


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -