TCustomWinSocket Send Error Problems
Posted on 2003-02-19
I've got a multithreaded Borland Builder C++ service application that normally runs on a NT 4 Server that has major problems when one of the sockets encounters a send error. The application uses a TServerSocket (Non-Blocking) as a listening socket that spawns TCustomWinSockets (also Non-Blocking) and processing threads upon connection (multiple connections from various clients possible). The threads are TThreads and are spawned and shutdown manually rather than with the TServerSocket component. All socket communication is currently handled within the main application thread and the data is buffered to the processing threads and safteyed using critical sections (there is no VCL component access from within the threads). All works well until one of the TCustomWinSockets encounters a Send error (ErrorEvent == eeSend / 10053). The socket disconnects as advertised and sets the Disconnect error and event and then it seems that all of the open TCustomWinSockets remain open but they appear to stop sending and receiving (or at least they don't trigger the events) and further connections are not possible although the listening socket is still active. The application doesn't lock up nor do the threads however, the service won't stop and the entire server must be rebooted before the application will run again. No Exceptions are noted in the logs however I do trap the socket error exception and attempt to deal with it (obviously not very well in this case :). Try/Catch on the Socket->SendText or Socket->Sendbuf do not display any triggered exceptions. This does not happen on Disconnect errors and I haven't encountered any of the other socket error types to know whether they cause the same problem or not. I'd like to keep the sockets async and have tried both Socket->SendText and Socket->Sendbuff with some monitoring. I've also tried placing the socket read/write routines inside of TThreads and using Synchronize with no success - same problem exists. Is there some type of cleanup on the TCustomWinSocket component or socket itself that needs to be performed when a send error is recieved? A lot (tons) more details available if needed. Any help or ideas appreciated.