0
我有這個Web服務器,我試圖使用TcpListener,但它不會接受我提出的一半請求。它在請求發生時簡單地掛在AcceptTcpClient
上,它在任何端口上的行爲也是一樣的。TcpListener不接受客戶端
this.main = new Thread(() =>
{
while (this.running)
{
TcpClient c = this.t.AcceptTcpClient();
new Task(() =>
{
handleClient(c);
}).Start();
}
});
this.main.Start();
究竟是你想用新的主題和新的任務這個代碼做的工作就好了。 https://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener(v=vs.110).aspx –