python - How to find out how many clients are on a certain address range? -


i tried googling didnt find anything... building port scanner , make so, can scan network range e.g 192.168.2.* , find out how many computers on range online. alot nmap. programming in python. possible in python?

here draft example can start with:

import socket  addr_range = "192.168.1.%d"  ip_address_up = []  # use udp.  s = socket.socket(socket.af_inet, socket.sock_dgram)  s.settimeout(2.0)  in range(1, 254):     try:         ip = addr_range %         socket.gethostbyaddr(ip)         ip_address_up.append(ip)     except socket.herror ex:         pass  print ip_address_up 

or using icmp (ping) rather thank udp:

import socket import ping  ip_address_up = []  addr_range = "192.168.1.%d"  in range(1, 254):           try:        ip = addr_range %        delay = ping.do_one(ip, timeout=2)        ip_address_up.append(ip)    except (socket.herror, socket.timeout) ex:        pass  print ip_address_up 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -