AcceptTcpClient vs AcceptSocket

扶醉桌前 提交于 2019-12-19 03:14:27

问题


I want to write a simple multi threaded server-client application and I've stumbled on those two while creating tcplistenr

public void serverListenr
{
        int MessageLength=0;
        TcpListener peerListener = _infrastructure_TcpServerAndClient.CreateNewTcpListenerANDstart();
        while (true)
        {
            //var Client = peerListener.AcceptTcpClient or   peerListener.AcceptSocket(); ?? 
           new Thread(ServeData).Start(client);
        }
....
}

they have the same description

What is the difference between those two ?


回答1:


AcceptTcpClient returns TcpClient, whereas AcceptSocket returns a Socket. Due to this, they can also throw different errors

Naturally your next question will be what's the difference between those two. TcpClient is a wrapper around a Socket, with some minor performance implications. See this.



来源:https://stackoverflow.com/questions/23852969/accepttcpclient-vs-acceptsocket

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!