Ejemplo n.º 1
0
        public RawServer(int port)
        {
            serverThread = new Thread(runThis);
            serverThread.Name = "Main Server";
            serverThread.Priority = ThreadPriority.AboveNormal;
            serverThread.IsBackground = true;

            System.Console.WriteLine("Starting Server");
            this.nw = new NetworkWorker(port);
            serverThread.Start();
        }
Ejemplo n.º 2
0
        public bool connect(string host, int port)
        {
            // Store server info
            this.server = new IPEndPoint(IPAddress.Parse(host), port);

            // Client may now try to connect
            this.curState = cState.TRYCONNECT;

            //Spawn the client reader/writer threads
            this.nw = new NetworkWorker(server);

            // Inform the client thread that the server info is ready
            ready.Release();

            // Send the handshake request to the server
            this.handshake();

            // Wait for the connection to be established
            while (this.curState == cState.TRYCONNECT) ;

            return true;
        }