예제 #1
0
        private void Connect()
        {
            Console.Out.WriteLine($"Trying to connect with server on ip {_serverAdress.Address}:{_serverAdress.Port}");
            // Create a TCP/IP socket.
            ISocketConnection socket = new SocketConnection(_serverAdress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); // TODO inject

            // Connect to the remote endpoint.
            try
            {
                socket.BeginConnect(_serverAdress, new AsyncCallback(ConnectCallback), socket);
            }
            catch (SocketException e)
            {
                Console.WriteLine($"Failed to open connection with StellaServer.{e.SocketErrorCode}.");
                Reconnect();
            }
        }