thanks alot!
that's all there is to it..so it's just a simple connect.

Dan M wrote:
> On Sat, 29 Oct 2005 20:21:20 -0700, eight02645999 wrote:
>
> > hi
> > in python, how do one query a port to see whether it's up or not?
> > thanks
>
> I'm an absolute beginner, but let's see if I can help. Assuming you want
> to check a port on another machine,
>
> import socket
> port=25                       # Port we want to test
> host=machine.to.test  # Either IP address or FQDN
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> try:
>       s.connect((host, port))
>       print "We made the connection"
> except socket.error:
>       print "Sorry, that port is not open"
> s.close
> 
> Does that help?
> 
> Dan

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to