diff --git a/source/Cosmos.System2_Plugs/System/Net/Sockets/TcpClientImpl.cs b/source/Cosmos.System2_Plugs/System/Net/Sockets/TcpClientImpl.cs index b70121e4fa..5d5aa27325 100644 --- a/source/Cosmos.System2_Plugs/System/Net/Sockets/TcpClientImpl.cs +++ b/source/Cosmos.System2_Plugs/System/Net/Sockets/TcpClientImpl.cs @@ -19,6 +19,11 @@ public static void Ctor(TcpClient aThis) { } + public static void Ctor(TcpClient aThis, string hostname, int port) + { + Connect(aThis, hostname, port); + } + public static void Ctor(TcpClient aThis, Socket acceptedSocket) { _clientSocket = acceptedSocket; @@ -39,30 +44,26 @@ public static int get_ReceiveBufferSize(TcpClient aThis) return Cosmos.System.Network.IPv4.TCP.Tcp.TcpWindowSize; } - public static void Connect(TcpClient aThis, string hostname, int port, [FieldAccess(Name = "System.Boolean System.Net.Sockets.TcpClient._active")] ref bool _active) + public static void Connect(TcpClient aThis, string hostname, int port) { - var address = IPAddress.Parse(hostname); - var endpoint = new IPEndPoint(address, port); + IPAddress address = IPAddress.Parse(hostname); + IPEndPoint endpoint = new(address, port); - _clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - _clientSocket.Bind(endpoint); - _clientSocket.Connect(address, port); - _active = true; + Connect(aThis, endpoint); } - public static void Connect(TcpClient aThis, IPAddress address, int port, [FieldAccess(Name = "System.Boolean System.Net.Sockets.TcpClient._active")] ref bool _active) + public static void Connect(TcpClient aThis, IPAddress address, int port) { - var endpoint = new IPEndPoint(address, port); + IPEndPoint endpoint = new(address, port); - _clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - _clientSocket.Bind(endpoint); - _clientSocket.Connect(address, port); - _active = true; + Connect(aThis, endpoint); } - public static void Connect(TcpClient aThis, IPEndPoint remoteEP, [FieldAccess(Name = "System.Boolean System.Net.Sockets.TcpClient._active")] ref bool _active) + private static void Connect(TcpClient aThis, IPEndPoint endpoint) { - throw new NotImplementedException(); + _clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + _clientSocket.Bind(endpoint); + _clientSocket.Connect(endpoint.Address, endpoint.Port); } public static void Connect(TcpClient aThis, IPAddress[] ipAddresses, int port)