1 // =================================
 2 // Copyright (c) 2021 Seppo Laakko
 3 // Distributed under the MIT license
 4 // =================================
 5 
 6 using System;
 7 using System.IO;
 8 
 9 namespace System.Net.Sockets
10 {
11     public class TcpClient
12     {
13         public TcpClient() : socket()
14         {
15         }
16         public TcpClient(const string& nodeconst string& service) : socket(nodeservice)
17         {
18         }
19         public TcpClient(const string& nodeconst string& serviceConnectOptions options) : socket(nodeserviceoptions)
20         {
21         }
22         public nothrow TcpClient(TcpSocket&& socket_) : socket(Rvalue(socket_))
23         {
24         }
25         public void Close()
26         {
27             socket.Close();
28         }
29         public void Connect(const string& nodeconst string& service)
30         {
31             Connect(nodeserviceConnectOptions.none);
32         }
33         public void Connect(const string& nodeconst string& serviceConnectOptions options)
34         {
35             Close();
36             socket.Connect(nodeserviceoptions);
37         }
38         public SharedPtr<ByteStream> GetStream()
39         {
40             return SharedPtr<ByteStream>(new BufferedByteStream(SharedPtr<ByteStream>(new NetworkByteStream(Rvalue(socket)))));
41         }
42         public TcpSocket& ContainedSocket()
43         {
44             return socket;
45         }
46         private TcpSocket socket;
47     }
48 }