LISTEN sockets associated with client connections

  • Thread starter Thread starter John
  • Start date Start date
J

John

I have a client process that behaves like a Telnet client,
so it connects to a Telnet server. However it does not
necessarily log in to the Telnet server. When it does not
log in, of course as expected, the Telnet server drops the
connection after a period of time, varying from 1 to
several minutes.

What I have noticed when this occurs, over and over again
that each time this occurs WinSock or Windows networking
creates a LISTEN socket that corresponds with the
connection. When the Telnet server drops the connection
due to the log in not being completed, my client receives
notice of this via a "end of file" notification; zero
return status. My client reacts to this "failed"
connection by closing the connection and opening a new
socket/connection.

What I have noticed is that each time this occurs the
LISTEN socket that Winsock/Windows creates corresponding
to my client connection, stays around. It is not
terminated in conjunction with my closing of the "failed"
connection.

My questions are first of all, why does Winsock/Windows
create this LISTEN socket for my client connections?

Secondly, how can I get rid of this LISTEN socket when I
close the connection?

Thanks for your insight.
 
Just in case someone might have actually read this and is studying it
and/or has similar questions, I discovered my problem. Since this
code was ported from UNIX, I was using a simple close to remove the
"failed" socket. Rereading the MS sockets doc, I tried replacing the
"close" with a "closesocket" and that resolved my problem. The
LISTENING socket goes away with the client socket and my handle count
stays steady.
 
Back
Top