View Full Version : Net utilities for Python
Benny
07-08-2002, 03:37 AM
I had a look at the standard modules but couldn't find anything, was curious if python has any way to do simple network things such as "ping" and "gethostbyaddr"?
I'm guessing a ping function could be created using the socket module or some sort, but has anyone come across this functionality built in (or an already made module)?
Cheers.
Bradmont
07-08-2002, 04:41 AM
socket stuff: http://python.org/doc/current/lib/module-socket.html
that has gethostbyname, etc, in general, look here: http://python.org/doc/current/lib/lib.html for any module documentation.
Benny
07-08-2002, 09:40 AM
oooh so it does.
Damn I must be blind - I looked throug the socket module docs....oh well.
Thanks Bradmont.
inkedmn
07-08-2002, 12:01 PM
most of the major internet protocols have their own python libs (ftplib, smtplib, poplib, telnetlib, etc.)
jemfinch
07-08-2002, 04:10 PM
"ping" requires sending ICMP packets, which requires SOCK_RAW, something that's not available in every operating system. It also requires root privileges in most operating systems.
You might look into a Python binding for libpcap, a library that makes use of SOCK_RAW a bit easier.
Jeremy
Benny
07-08-2002, 08:45 PM
Originally posted by jemfinch
"ping" requires sending ICMP packets, which requires SOCK_RAW, something that's not available in every operating system. It also requires root privileges in most operating systems.
You might look into a Python binding for libpcap, a library that makes use of SOCK_RAW a bit easier.
Ah okay, cheers.
I was just curious cause I know Perl has Net::Ping and was just wondering if python had anything similar.
A ping utility would have helped with a little script I was writing, ended up having to do it in Perl instead - Yuk.....
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.