HumbleNetwork.HumbleClient.Connect C# (CSharp) Method

Connect() public method

public Connect ( string host, int port ) : HumbleClient
host string
port int
return HumbleClient
        public HumbleClient Connect(string host, int port)
        {
            if (_tcpClient.Connected == false)
            {
                try
                {
                    _tcpClient.Connect(host, port);
                }
                catch (SocketException ex)
                {
                    if (ex.ErrorCode == 10056)
                    {
                        _tcpClient.Close();
                        _tcpClient = new TcpClient();
                        _tcpClient.Connect(host, port);
                    }
                }
            }

            CreateStream();
            return this;
        }

Usage Example

Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            //// create the server, configure echo command and start listening
            var server = new HumbleServer();
            server.AddCommand("echo", () => new EchoCommand());
            server.Start(0);

            //// create the client, connect to the server, send the command and the parameters
            var client = new HumbleClient();
            client.Connect("localhost", server.Port);
            client.Send("echo").Send("hello world");

            Console.WriteLine("Client received: " + client.Receive());
            Console.ReadKey();
        }
All Usage Examples Of HumbleNetwork.HumbleClient::Connect