The Joel on Software Discussion Group (CLOSED)

A place to discuss Joel on Software. Now closed.

This community works best when people use their real names. Please register for a free account.

Other Groups:
Joel on Software
Business of Software
Design of Software (CLOSED)
.NET Questions (CLOSED)
TechInterview.org
CityDesk
FogBugz
Fog Creek Copilot


The Old Forum


Your hosts:
Albert D. Kallal
Li-Fan Chen
Stephen Jones

Windows socket question - finding process tying up a port

I am developing a Win32 application that creates a listener at a particular port. In debugging, the application has crashed several times. Now the app cannot start successfully because something is apparently listening at the port that it tries to open and listen at. I had assumed that a zombie process or thread was spun off from my app that is holding onto that port. But I do not see my application in the task manager list.

If I do "netstat -a -b" I eventually see the listing for port 20000, but the listing does not identify the program that is listening. It just says "system".

What can be done to clobber something like this short of rebooting?
Bored Bystander Send private email
Saturday, April 14, 2007
 
 
natstat -a -o
lemon obrien Send private email
Saturday, April 14, 2007
 
 
Ah, a column for PID. Muchas gracias.
Bored Bystander Send private email
Saturday, April 14, 2007
 
 
FYI: I'm by no means an expert, but I was playing around with the REUSEADDR socket options and it appears that setting it will let you effectively steal away a port and listen on it even if someone else is already listening on it.  This was on Win XP.
Doug
Saturday, April 14, 2007
 
 
It's likely what you're running into is a socket in the TIME_WAIT state. The TCPView utility from sysinternals can show you if this is the case.

Rather than try to explain it here, I'll let you first figure out if this is the case. If so, a quick Google search for TIME_WAIT should provide more than enough explanation.

Saturday, April 14, 2007
 
 
ActivePort from http://www.protect-me.com/freeware.html can provide you with that information.
Methy
Saturday, April 14, 2007
 
 
A TCP connection cannot transition from the LISTEN state to the TIME-WAIT state, so it's unlikely that the crashed listen socket somehow transitioned to the TIME-WAIT state.

Even if it had, OP reported that the netstat output had shown the socket with the desired port number was in the LISTEN state, not the TIME-WAIT state.
Ian Johns
Sunday, April 15, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz