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

Rainer Stratmann RainerStratmann at t-online.de
Fri May 29 19:04:29 CEST 2009


May be socketoption so_linger would be a solutuion.
http://www.developerweb.net/forum/archive/index.php/t-2982.html

Rainer

Am Freitag, 29. Mai 2009 18:43 schrieb Luca Olivetti:
> 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



More information about the fpc-pascal mailing list