Re: Check for activity on TCP port



On May 12, 6:53 pm, "Peter Duniho" <NpOeStPe...@xxxxxxxxxxxxxxxx>
wrote:
On Sat, 12 May 2007 14:44:31 -0700, Sir C4 <Vagyok...@xxxxxxxxx> wrote:
[...]
I'm looking for an event that will fire once a tcp port moves from the
listening status to established status.

You should probably learn more about TCP first.

There's no such thing as a TCP port moving "from listening status to
established status". An entirely new connection, with the "established"
status, is created when an application with a "listening" TCP port accepts
the connection. But the "listening" TCP port remains, and is still
listening for new connections.

I want this to run as a
service so I don't want it to chew up cycles constantly checking for a
specific port to move form listening to established that's why I ask
for an event.

Short of sniffing the network traffic and watching for TCP connections
being created, I'm not aware of any way to do what you want. Not directly
anyway.

One thing you could do is poll the TCP status and check for new
"established" connections on the same port as a "listening" port.
Obviously you wouldn't want to poll too often (maybe once every 5 or 10
seconds), but this would be one way to do it.

The obvious problem with this is that a connection could be closed and
then reopened between the time you've polled, or opened and closed for
that matter. You won't get guaranteed notification of network connection
changes this way, but it might be close enough for your purposes. Depends
on what you're actually doing.

Basically I want to execute some code once the port
moves from listening to established, and then run some clean up code
once it moves from established back to listening.

If you think it might be useful for getting better advice, you might
consider being more specific about the "clean up code". I'm having a hard
time imagining what one process would be able to usefully "clean up" in
response to some other process connecting or disconnecting TCP
connections. There's a small possibility that there's an entirely
different approach to accomplish what you're trying to do, but no one can
offer that information if they don't know what the end goal here is.

Pete

Pete,

Thanks for your insight. Basically I'm using VNC for remote
administration. Vista's new aero glass slows down the screen refresh
rate. Basically I want to watch for the VNC connection, when it's
detected, disable the aero experience, and when the connection is
closed, turn aero back on.

I think your explination will work out just fine.

.



Relevant Pages

  • Re: VNC Problem
    ... 01/10/2004 18:24:45 Listening for VNC connections on TCP port 5901 ... 01/10/2004 18:24:45 Listening for HTTP connections on TCP port 5801 ...
    (comp.os.linux.networking)
  • Re: Check for activity on TCP port
    ... There's no such thing as a TCP port moving "from listening status to established status". ... An entirely new connection, with the "established" status, is created when an application with a "listening" TCP port accepts the connection. ... If you think it might be useful for getting better advice, you might consider being more specific about the "clean up code". ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: rendom /prepare failed to bind to server
    ... Attempting to resolve name to IP address... ... TCP port 1753 (unknown service): NOT LISTENING ...
    (microsoft.public.windows.server.active_directory)
  • Re: No incoming mail from outside -- FIXED
    ... Exchange System Manager to Default Virtual SMTP Server properties and ... > I reran CEICW and ISA has rules allowing TCP port 25 in and out to/from ... > Portqry and Telnet from local addresses show Exchange is listening on TCP ...
    (microsoft.public.windows.server.sbs)
  • Re: Active FTP PORT command - port number
    ... The PORT request has a parameter in the form ... meaning that the client is listening for connections on TCP port ... It will change from connection to connection. ...
    (comp.unix.admin)