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?
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?