Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Microsoft.SPOT;
- using System.Net.Sockets;
- using System.Net;
- using System.Threading;
- using System.Xml;
- using Microsoft.SPOT.Net.NetworkInformation;
- namespace test {
- public class Program {
- private static Socket socket_;
- private static NetworkInterface NI_;
- public static void Main() {
- NI_ = NetworkInterface.GetAllNetworkInterfaces()[0];
- NI_.EnableStaticIP("192.168.1.201", "255.255.255.0", "192.168.1.1");
- Socket listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
- IPEndPoint ep = new IPEndPoint(IPAddress.Any, 3000);
- listenSocket.Bind(ep);
- listenSocket.Listen(5);
- Debug.Print("Waiting for connection...");
- socket_ = listenSocket.Accept();
- socket_.ReceiveTimeout = 10000; ;
- Debug.Print("Got socket connection from: " + socket_.RemoteEndPoint);
- new Thread(new ThreadStart(ProcessRequest));
- Thread.Sleep(Timeout.Infinite);
- }
- private static void ProcessRequest() {
- try {
- NetworkStream nwstream = new NetworkStream(socket_, true);
- XmlReader xmlReader = XmlReader.Create(nwstream);
- while (xmlReader.Read()) {
- Debug.Print("Read something out of xml...");
- }
- } catch (Exception ex) {
- Debug.Print(ex.ToString());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement