Re: query a port
- From: eight02645999@xxxxxxxxx
- Date: 29 Oct 2005 23:21:16 -0700
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
.
- Follow-Ups:
- Re: query a port
- From: Dan M
- Re: query a port
- References:
- query a port
- From: eight02645999
- Re: query a port
- From: Dan M
- query a port
- Prev by Date: Re: Automatic binding of **kwargs to variables
- Next by Date: Re: Scanning a file
- Previous by thread: Re: query a port
- Next by thread: Re: query a port
- Index(es):
Relevant Pages
|