Socket connection delay in asp.net

P

Paul

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top