1
2
3
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& node, const string& service) : socket(node, service)
17 {
18 }
19 public TcpClient(const string& node, const string& service, ConnectOptions options) : socket(node, service, options)
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& node, const string& service)
30 {
31 Connect(node, service, ConnectOptions.none);
32 }
33 public void Connect(const string& node, const string& service, ConnectOptions options)
34 {
35 Close();
36 socket.Connect(node, service, options);
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 }