Maybe just watch this video: http://screencast.com/t/OWE1OWVkO
As you can see, the delay between the initiated connection (via telnet or firefox) and my program receives it first.
Here is the code pending connection
public IDLServer(System.Net.IPAddress addr,int port)
{
Listener = new TcpListener(addr, port);
Listener.Server.NoDelay = true;
Listener.Start();
ConnectionThread = new Thread(ConnectionListener);
ConnectionThread.Start();
}
private void ConnectionListener()
{
while (Running)
{
while (Listener.Pending() == false) { System.Threading.Thread.Sleep(1); }
Console.WriteLine("Client available");
TcpClient cl = Listener.AcceptTcpClient();
Thread proct = new Thread(new ParameterizedThreadStart(InstanceHandler));
proct.Start(cl);
}
}
(I had a problem with the code that got into the code block)
I tried a couple of different things, maybe I'm using TcpClient / Listener instead of a raw Socket object? This is not a required TCP thread that I know, and I tried to run everything in one thread, etc.
source
share