Socket connections piling up

We have a C socket client, who initiates the socket request. They close the socket connection after use. (They open multiple connections within a socket.

We have a java socket server (wM), who accepts the connections and send data through an OutputStream. We never close the OutStream and the Socket server.

Problem: When they open new connections, they sometimes get timeout, since server on our side cannot accept connections since there are threads already hanging from previous connections.

It’s a windows box on the server side. How can we dynamically kill the connection threads st the server. Or any other better solutions?

When the client makes the first connection, does it just use that for all connections there after? If so, I would suggest you make a solution that the server has a main port to listen on, and when the client does the first connect, the server gives a new quick port to connect to for further interaction. That way, your main two or three ports are open and you can have thousands of dynamic subconnections to work with. You can also have a thread manager on the server, where if ping() command doesn’t show an update after a certain time, you can just call the Thread.stop() method to rip down the thread. That would cause the port to be locked for a long while, but you gain room for memory and processing. Good day.

Yemi Bedu