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); } }
private static Socket InitSocket() { const Int32 c_port = 1001; Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, c_port); server.Bind(localEndPoint); server.Listen(1); // Debug.Print("InitSocket OK"); // return(server); }