本文介绍了AcceptTcpClient与AcceptSocket的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个简单的多线程服务器-客户端应用程序并且我在创建tcplistenr时偶然发现了这两个

I want to write a simple multi threaded server-client applicationand 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);
        }
....
}

它们具有相同的描述

这两者之间有什么区别?

What is the difference between those two ?

推荐答案

AcceptTcpClient 返回 TcpClient ,而 AcceptSocket 返回套接字.因此,他们也可能引发不同的错误

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

自然,您的下一个问题是这两者之间有什么区别. TcpClient Socket 的包装,对性能的影响很小.参见.

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.

这篇关于AcceptTcpClient与AcceptSocket的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 23:47