소켓과 tcpclient 객체 사이에서 변환 할 수 있습니까?
-
03-07-2019 - |
문제
여기에 또 다른 C#/. 순 질문은 필요 ...
당신이 가졌다면 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?
Get the underlying Socket using TcpClient.Client property.
다른 팁
From TcpClient to Socket is very easy. tcpClientInstance.Client
is the underlying Socket instance.
제휴하지 않습니다 StackOverflow