I am using the .Net socket class and I am using the following code:
socket.Shutdown(SocketShutdown.Both); socket.Disconnect(true);
Then it blocks exactly two minutes. I specified true because I am going to reuse the socket immediately and reconnect. Whether I have a Shutdown call or not, it blocks for two minutes. The only thing I can do is pass false to disable. But I want to reuse a socket.
Any ideas?
UPDATE:
I read the codes. I set the DontLinger parameter. It does not help.
UPDATE 2:
I added a network trace for the query:
Trace 1: using the DontLinger option
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()
Trace 2: using shutdown (SocketShutdown.Both);
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()
uriDium
source share