Jump to content

Eric Fleming Bonilha

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. Hello I have a weird problem, which has haunted me for some years now and I don't know exactly why it happen or how to solve it and now we have a critical customer installation that is experiencing this issue and we can't solve it. The problem is as follow.. I have a TCP Socket Server using TWSocketServer which listens on port 8600. This socket is created and processed by the application main thread.. so, basically, all windows messages for network input on this socket is processed by the main thread... The problem happens when I have any lengthy operation going on on the same thread (main thread), so, on busy installations, we might have a process that takes 5 seconds to complete, and it is processed in the main thread (i know... it should be parallel, but for some tasks that we do it has to be in the main thread), when that happens and the main thread will "hang" for a few seconds because its doing some work, and while its doing it, obvisouly it won't respond to windows messages for new incomming connections... so, the problem happens when I have multiple incomming connections while the thread is processing something else and what actually happens is that looks like windows will stop responding to new incomming connections on port 8600, even after the thread is back from the lengthy task.. so, basically its like the socket has been closed, but all connections that are already open, will remain open and processing normally, but it will not accept new connections... in order to make it work again we have to close the socket server and open it again (make it listen to port 8600) again, then all incomming connections will work again.. The problem will never happen if new connections are not being attempted while the thread is busy... it only happens when the thread is busy and there are multiple new incomming connections while its busy. I believe that this happens because the application is not responding to windows incomming socket connection messages in a timely manner, then the OS will "close" the socket, but we never get notified in the application that this happened.. to the application, the socket is still listening.. if I go to netstat -an, it will show that port 8600 is listening.. but windows will not accept any new connection (but any connection that was already there will still communicate and work) Do you know how to fix this issue? Is there any option of the OS to not close this socket? Thanks
×