I wish someone could help , i dont know if its a bug ....
here is a code that worked on two pcs without any problem ..
i am trying the same on the netduino plus
Netduino plus code
LedPin = new OutputPort(Pins.ONBOARD_LED, false); Interface = NetworkInterface.GetAllNetworkInterfaces()[0]; Interface.EnableStaticIP("192.168.15.4", "255.255.255.0", "192.168.15.1"); Thread.Sleep(5000); Debug.Print("ip: " + Interface.IPAddress); LedPin.Write(true); Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPEndPoint ip = new IPEndPoint(IPAddress.Any, 90); sock.Bind(ip); sock.Listen(1); Socket _sock; NetworkStream _NetStream; while (true) { _sock = sock.Accept(); _NetStream = new NetworkStream(_sock); for (int i = 0; i < 10; i++) _NetStream.WriteByte(48); _NetStream.Close(); _sock.Close(); }
Here Is The Pc Code:
private void button1_Click(object sender, EventArgs e) { Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); sock.Connect(IPAddress.Parse("192.168.15.4"), 90); NetworkStream ns = new NetworkStream(sock); char x; for (int i = 0; i < 10; i++) x = (char)ns.ReadByte(); ns.Close(); sock.Close(); }
it gets an exception microsoft.spot.io , still dont know why , i would like some help