Beispiel #1
0
        public static void Main()
        {
            bool ledState = false;

            led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, ledState);
            led.Write(false);
            //USB Device
            Program.InitDevice();
            //Network
            Program.InitNetwork();
            //Socket
            Socket server = Program.InitSocket();

            //
            while (true)
            {
                // Wait for a client to connect.
                Socket clientSocket = server.Accept();
                // Process the client request.  true means asynchronous.
                Debug.Print("New Client");
                new ProcessClientRequest(clientSocket);
                Debug.Print("Client is working");
            }
            //
        }
        public static void Main()
        {
            const Int32 c_port = 2000;

            byte[] ip      = { 192, 168, 1, 100 };
            byte[] subnet  = { 255, 255, 255, 0 };
            byte[] gateway = { 192, 168, 1, 1 };
            byte[] mac     = { 0x00, 0x26, 0x1C, 0x7B, 0x29, 0xE8 };
            WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10,
                                (Cpu.Pin)FEZ_Pin.Digital.Di7, true);
            NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac);
            NetworkInterface.EnableStaticDns(new byte[] { 192, 168, 1, 1 });
            Socket server = new Socket(AddressFamily.InterNetwork,
                                       SocketType.Stream, ProtocolType.Tcp);
            IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, c_port);

            server.Bind(localEndPoint);
            server.Listen(1);
            while (true)
            {
                // Wait for a client to connect.
                Socket clientSocket = server.Accept();
                // Process the client request. true means asynchronous.
                new ProcessClientRequest(clientSocket, true);
            }
        }