是否有可能Socket和TcpClient的对象之间的转换? [英] Is it possible to convert between Socket and TcpClient objects?
问题描述
下面是对好奇仅仅是基于另一种C#/。NET的问题不止一个立即的需要 ...
如果你有一个插槽
实例,你想要把它包在更高级别的的TcpClient
类,是是可能的,你会怎么做呢?
相反,如果你有的TcpClient
的实例,是有可能得到的潜在插槽
?
如果你有一个Socket实例,你 想要把它包在更高级别 TcpClient的类,是可能的, 你会怎么做呢?
Socket套接字= ...;
TcpClient的客户端=新的TcpClient();
client.Client =插座;
相反,如果你有一个实例 TcpClient的,是有可能得到 底层的Socket?
获取底层的插座中使用<一个href="http://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient.client.aspx">TcpClient.Client属性。
Here's another C#/.NET question based merely on curiousity more than an immediate need ...
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?
Conversely if you have an instance of TcpClient
, is it possible to get the underlying 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?
Get the underlying Socket using TcpClient.Client property.
这篇关于是否有可能Socket和TcpClient的对象之间的转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!