Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sockets re-visted Win 2003K system

Status
Not open for further replies.

cdlvj

MIS
Joined
Nov 18, 2003
Messages
678
Location
US
I have a server (as a service) which listens for socket connections 24x7. It is message logging system, connection opens and a child is forked to handle traffic, and main program goes back to listen. The child simply puts the messages into a MSSQL Table.

I have three service programs which open the connect and work all day sending messages. Then I have many short programs which kick off during the day and connect, send messages, and disconnect.

The problem I have is after a while the server stops responding to new connections. The (threads) (child) still continue to respond to the services.

After more re-tooling, discovered that the server's child thread has to close the socket, otherwise the socket stays in a CLOSE_WAIT state. It hangs around forever taking up a slot. The OS is supposed to take care of this condition, but it is not. My constructor in the client program is sending a last message, and when the server child gets the message, it terminates. But I still have the last one out there hanging on. It gets re-used, but then continues to go to CLOSE_WAIT. My question is Does it matter which issues the close socket 1st Client or Server?








 
The parent pid for my process (service) is 3840.
It failed today and the log shows a child started with a pid of 3840. How can this be?

Code:
20060427_110051:Child spawned and Return to listen Socket
20060427_110051:Child Started: -2328
20060427_110054:Close and exit -2328
20060427_110850:Close and exit -1996
20060427_112340:Child spawned and Return to listen Socket
20060427_112340:Child Started: -428
20060427_112342:Close and exit -428
20060427_112951:Child spawned and Return to listen Socket
20060427_112951:Child Started: -1576
20060427_112952:Close and exit -1576
20060427_121455:Child spawned and Return to listen Socket
20060427_121455:Child Started: -3020
20060427_121457:Close and exit -3020
[b]20060427_134113:Child Started: 3840
20060427_135351:Close and exit 3840[/b]
20060427_142308:Close and exit -2868
20060427_142358:Close and exit -3632
20060427_142504:Close and exit -1164
20060427_142901:Close and exit -3168
 
I would tentatively conclude that Windows was a bit broken. You don't have a scrap PC that you could stick Linux on? It all gets very easy then and you can use DBI to update your table.

Yours,

fish

PS - I've seen dangling connection problem on AIX as well.

["]As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.["]
--Maur
 
Would rebuilding the winsock help?

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
I agree that this would be o so simple in UNIX, but This is a all windows shop.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top