Re: query a port



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: MBSA and MSs attempts at "security"
    ... >the port status of TCP and UDP ports on a computer you choose. ... you can also query an LDAP service. ... LDAP query and interpret an LDAP server's response to ...
    (Focus-Microsoft)
  • Windows Service Project
    ... I've started my first practice windows service project in C#, ... there are three key moments which prevent me from programming such ... How do I make the service listen on any port? ... What is the event that is raised, when some query ...
    (microsoft.public.dotnet.languages.csharp)
  • Services, C#
    ... How do I make the service listen on any port? ... What is the event that is raised, when some query actually arrives at that port? ... If necessary and if you can, disregard the existing standard communication protocols, as I will be programming the client side too, so I suppose it doesn't matter what's the format of my response. ...
    (microsoft.public.dotnet.languages.vc)
  • Services, C#
    ... I've started my first practice windows service project in C#, ... How do I make the service listen on any port? ... What is the event that is raised, when some query actually arrives at that port? ... If necessary and if you can, disregard the existing standard communication protocols, as I will be programming the client side too, so I suppose it doesn't matter what's the format of my response. ...
    (microsoft.public.dotnet.languages.vc)
  • LDAP Queries to Windows Global Catalog
    ... I really hope this is the correct newsgroup to post this question ... domain LDAP query, I need to make a query against the ... Global Catalog (port 3268), but I can't figure out the configuration I ...
    (comp.os.linux.networking)