[fpc-pascal] "Aborting " a socket operation under Linux

Luca Olivetti luca at ventoso.org
Fri May 29 18:43:51 CEST 2009


I have a thread managing a socket (using synapse but I don't think that
it matters, just keep in mind that each operation is blocking).
Inside the thread, I try to connect, send and read in a loop.
If I see an error, I just exit the loop and, if
the thread is terminated, that's it, otherwise I try a new connection
and so on and so forth.
In the thread destructor (called in the context of the main thread),
apart from terminate, I use the synapse AbortSocket call (which in turn 
calls CloseSocket, which in turn calls fpClose under linux), which 
supposedly terminates any pending call on the socket in the thread, so 
it can terminate immediately.
It works fine under windows (i.e the socket calls terminate immediately 
inside the thread), but under Linux it doesn't until the timeout 
expires, and that's not very convenient, especially if I'm trying to 
quickly close the program and I have many of those threads running.
Is there a way to make the pending call exit immediately?

Bye
-- 
Luca



More information about the fpc-pascal mailing list