> t see where the option SO_LINGER is used instead the 24 seconds.
24 seconds is the default FNET_TCP_TIME_WAIT. As Andrey says, the default for this in "normal computers" (PC, Linux) is 2 minutes, and that can chew up a lot of memory. 24 seconds is fine. It has nothing t do with the "linger time".
I googled for "tcp linger explanation" and came up with some interesting links:
Graceful Shutdown, Linger Options, and Socket Closure (Windows)
The above says how Windows programmers are meant to program with TCP sockets. Open it and scroll down to the "Client Side, Server Side" diagram. The bit that should surprise you is where the client has CLOSED from its end, but is still required to READ data from the other end AFTER the "close". This is normal TCP operation. You should be able to set up a connection which is "closed" in one direction, but still should be able to send data in the other end "for ever". This is useless, but a feature of the way TCP works. The problem is that most people don't know this and don't code that way so they don't "read after close" when they should and that leaves the connection "stuck".
The above link also has in the comments details that Windows TCP sockets simply don't seem to work properly in Windows 7 and that the LINGER options no longer work. So if you're using FNET and connecting to and from Windows, these problems might show up at the FNET end.
sockets - TCP option SO_LINGER (zero) - when it's required - Stack Overflow
The above is a VERY good summary of TCP connection closing, problems the "bad solution of using a LINGER time of zero", and how to write your protocols properly to not require this.
From your original post:
> What i do is; when the "hercules" connect i send "hello world"
> and next I close the socket.
From the previous link, it is far better to have the client close the socket. Closing from the server end necessarily causes entry into TIME_WAIT. This should only take 24 seconds though, and then you should have the memory back. Have you waited for this time?
4.6 - What exactly does SO_LINGER do? (Page 1) / UNIX Socket FAQ / UNIX Socket FAQ
The above details how SO_LINGER works and what the three different settings (off, on-zero, on-non-zero) mean, or are MEANT to mean.
Andrey, I'm pretty sure FNET implements the "on and zero" the way it details (sends an immediate abort/RST), but does the FNET socket block in the "on and non-zero" case as detailed above, or does it do something else?
> But as Tom says SO_LINGER is ignored unless it is a parameter of zero,
Further down in that function SO_LINGER with a non-zero parameter sets the connection timer to that value. The Zero state does work in all non-TIME_WAIT states, and you shouldn't be in that state when you call fnet_tcp_close() anyway.
Tom