Scanning a Subnet with python?
cliechti at gmx.net
Wed Nov 28 20:53:54 CET 2001
[posted and mailed]
"Axel" <axonice at web.de> wrote in news:9u2d62$5k5$07$1 at news.t-online.com:
> I want to scan a subnet with python, but I don't know how?
> What I want to do:
> I want to write a chat program in pure python(with a Tkinter gui). It
> should include both client and server, so that the first user opens a
> server and all other connect to this server. Further, the program
> should be OS independent.
> My problem:
> I want to give the user possiblity to scan the subnet wheter there is a
> or not, but how can I perform such a test?
you chat programm opens a server on a UDP port. when a new client joins the
net it sends a broadcast to this port. all servers will respond to this
broadcast and send back a "hello" to the client. the client will get
messages from all servers in the same subnet in a few seconds or less.
i have some exaple code but on an other machine. drop me a line if your
you don't need a dedicated server. each chat programm can be server and
client at the same time:
- display incomming messages
- send "hello" on search broadcasts
- send messages to one machine or
- send messages as broadcast to all machines
you should think up a simple protocol for you packets.
differentiate between control messages and text messages.
> If I get the subnet mask, I will test every IP wheter the computer is
> up and wheter there is a runnig server on it, but how can I get the
> subnet mask using python?
all not needed when you use UDP broadcasts...
> Or, does anyone know a better way to scan a subnet with python?
> Python comes with batteries included,
> but does it have an otto-motor too?
Chris <cliechti at gmx.net>
More information about the Python-list