本文介绍了是否有可能Socket和TcpClient的对象之间的转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是对好奇仅仅是基于另一种C#/。NET的问题不止一个立即的需要 ...
如果你有一个插槽
实例,你想要把它包在更高级别的的TcpClient
类,是是可能的,你会怎么做呢?
相反,如果你有的TcpClient
的实例,是有可能得到的潜在插槽
?
解决方案
Socket套接字= ...;
TcpClient的客户端=新的TcpClient();
client.Client =插座;
获取底层的插座中使用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
?
解决方案
Socket socket = ...;
TcpClient client = new TcpClient();
client.Client = socket;
Get the underlying Socket using TcpClient.Client property.
这篇关于是否有可能Socket和TcpClient的对象之间的转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!