I'm trying to use a socket connection from within an asp.net
application.
It works, but somehow opening the socket seems to be extremely slow.
It finally connects and you can transfer information, but it hangs for
at least 5 seconds before the connection completes. Interestingly, a
second connection to the same port in a very short time interval (<1s)
returns instantly, but if you wait for a couple of seconds a new
connection again takes very long. The same code in a standalone .net
application does not show this problem, so it must be something with
asp.net.
This is a piece of code in C# that shows this behavour in an asp.net
application (supposed something is listening on the local computer at
port 7000)
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
IPHostEntry ipHostInfo = Dns.Resolve("localhost");
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint ipe = new IPEndPoint(ipAddress,7000);
s.Connect(ipe);
Any help appreciated!
Paul