Windows – When Does the Linux & Windows’ Samba Port Connection Close

connectionsnetstatnetworkingsambawindows

After connecting to a samba share, then disconnecting, netstat still shows that the ports are ESTABLISHED, even when the clients are on SUSPEND, HIBERNATE, or have SHUTDOWN. Looking over the samba documentation, I know now that I can set a period so those ports can TIMEOUT after said time. But without this variable: How long does the

A) Windows (Win 7 x64 Home) connection (445 shown in my case) take to close?

B) Linux (Ubuntu 11.04 x86) connection (139/445 shown in my case) take to close?

Best Answer

To clarify: Before this question, from a pretty much "stock" configuration, I was getting the symptoms shown above. After this question, and some tinkering, I have gotten the time down somehow to disconnect minutes after LOGOUT, ETC.; without the need to resort to the solutions below.

The best, trustworthy, answer I can find is from O'Reilly Online.

SO_KEEPALIVE

This initiates a periodic (four-hour) check to see if the client has disappeared. Expired connections are addressed somewhat better with Samba's keepalive and dead time options. All three eventually arrange to close dead connections, returning unused memory and process-table entries to the operating system.

So basically, it is closed after just 4 hours! But as also said, it's best to use Samba's keepalive option to close this far gap. Of course, even then, since Samba's/Windows's/Etc. ability to close and reopen said ports is of no problem, I will resort to using deadtime instead to just close the unused gap; whether or not the client is still there.