Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does .Net Socket.Disconnect take two minutes?
    text
    copied!<p>I am using .Net's socket class and I am using the following code:</p> <pre><code>socket.Shutdown(SocketShutdown.Both); socket.Disconnect(true); </code></pre> <p>This then blocks for exactly two minutes. I have specified true because I am going to reuse the socket immediately and re-establish the connection. Whether I have the Shutdown call in there or not it blocks for two minutes. The only thing I can do is pass false to disconnect. But I want to reuse the socket.</p> <p>Any ideas?</p> <p><strong>UPDATE:</strong></p> <p>I have read the codes. I have set the DontLinger option. It does not help.</p> <p><strong>UPDATE 2:</strong></p> <p>I have added a network trace as per request:</p> <p>Trace 1: Using the DontLinger option</p> <pre><code>System.Net.Sockets Verbose: 0 : [4668] Socket#5009246::Socket(InterNetwork#2) System.Net.Sockets Verbose: 0 : [4668] Exiting Socket#5009246::Socket() System.Net.Sockets Verbose: 0 : [4668] Socket#5009246::Connect(eee:nnnn#-2063562120) System.Net.Sockets Information: 0 : [4668] Socket#5009246 - Created connection from aaa.bbb.ccc.ddd.eee:nnnnn to www.xxx.yyy.zzz.:mmmm. System.Net.Sockets Verbose: 0 : [4668] Exiting Socket#5009246::Connect() System.Net.Sockets Verbose: 0 : [4668] Socket#5009246::Disconnect() System.Net.Sockets Verbose: 0 : [4668] Exiting Socket#5009246::Disconnect() </code></pre> <p>Trace 2: Using the Shutdown(SocketShutdown.Both);</p> <pre><code>System.Net.Sockets Verbose: 0 : [0300] Socket#5009246::Socket(InterNetwork#2) System.Net.Sockets Verbose: 0 : [0300] Exiting Socket#5009246::Socket() System.Net.Sockets Verbose: 0 : [0300] Socket#5009246::Connect(ddd:eeeee#-2063562120) System.Net.Sockets Information: 0 : [0300] Socket#5009246 - Created connection from aaa.bbb.ccc.ddd:eeee to www.xxx.yyyy.zzzz:nnnnn. System.Net.Sockets Verbose: 0 : [0300] Exiting Socket#5009246::Connect() System.Net.Sockets Verbose: 0 : [0300] Socket#5009246::Shutdown(Both#2) System.Net.Sockets Verbose: 0 : [0300] Exiting Socket#5009246::Shutdown() System.Net.Sockets Verbose: 0 : [0300] Socket#5009246::Disconnect() System.Net.Sockets Verbose: 0 : [0300] Exiting Socket#5009246::Disconnect() </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload