这是另一个C#/ .NET问题,只是基于好奇而不是立即需要…
如果你有一个Socket实例,并且想把它包装在更高级别的TcpClient类中,那么可以这样做,你会怎么做?
相反,如果你有一个TcpClient的实例,是否可以获得底层的Socket?
解决方法
If you had a Socket instance and you
wanted to wrap it in the higher-level
TcpClient class,is that possible and
how would you do it?
Socket socket = ...; TcpClient client = new TcpClient(); client.Client = socket;
Conversely if you have an instance of
TcpClient,is it possible to get the
underlying Socket?
使用TcpClient.Client属性获取底层Socket.