Exemple #1
0
        public void ConnectAsClient(string ipaddress, int port)
        {
            LogFile.WriteLine("NetworkController.  Connect as client to " + ipaddress + " " + port);
            IsServer    = false;
            connections = null;
//            connectionopen = false;
            connectiontoserver = new NetworkLevel2Connection(this, new ConnectionInfo(null, System.Net.IPAddress.Parse(ipaddress), port), false);
            networkimplementation.ConnectAsClient(ipaddress, port);
        }
            public void Go(string ipaddress, int port)
            {
                INetworkImplementation net = NetworkImplementationFactory.CreateNewInstance();

                net.ConnectAsClient(ipaddress, port);
                net.ReceivedPacket += new Level1ReceivedPacketHandler(net_ReceivedPacket);
                net.Send(Encoding.UTF8.GetBytes("Hi, this is a test"));
                while (true)
                {
                    net.Tick();
                    Thread.Sleep(50);
                }
            }