Re: query a port



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

.



Relevant Pages

  • Re: RM/Cobol - Printing in XP
    ... Dan wrote: ... > used for the physical local printer port on the clients computer. ... USP ports can't be accessed from a DOS program and WinPrinters take some ...
    (comp.lang.cobol)
  • Re: Possibly OT: Postfix stopped working (firestarter problem???)
    ... Dan Roozemond banaan.org> writes: ... >> I have this strange problem that Postfix stopped working all of a ... > It could be the case that your ISP all of a sudden decided it is a very bad ... > why internet port scanners see port 25 in stealth mode. ...
    (Debian-User)
  • Re: Using postfix to forward to other server on another port
    ... Dan wrote: ... > However, my friend is not. ... I configured postfix to listen on port ... Ok...the relaying machine spits this back as an error message: ...
    (comp.os.linux.networking)
  • Re: Cannot solve SSL in IIS 6 with host headers
    ... Dan - thanks. ... My host indicates port 443 is open, ... mydomain.com via HTTP but not via HTTPS. ... message and nothing appears in the IIS log for the failed HTTPS access ...
    (microsoft.public.inetserver.iis.security)
  • Re: What are modules really for?
    ... > Dan wrote: ... >> You might think of modules in Python as like packages in Java. ...
    (comp.lang.python)