Advertisement
Guest User

Untitled

a guest
Jan 14th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Net;
  4. using System.Net.Sockets;
  5. using System.Text;
  6. using System.Threading;
  7. using Microsoft.SPOT;
  8. using Microsoft.SPOT.Hardware;
  9. using Microsoft.SPOT.Net.NetworkInformation;
  10. using SecretLabs.NETMF.Hardware;
  11. using SecretLabs.NETMF.Hardware.Netduino;
  12.  
  13.  
  14. namespace wiznetTeste
  15. {
  16. public class Program
  17. {
  18. public static void Main()
  19. {
  20. SecretLabs.NETMF.Net.Wiznet5100 wiznet = new SecretLabs.NETMF.Net.Wiznet5100(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10);
  21. NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];
  22. networkInterface.PhysicalAddress = new byte[] { 0x5C, 0x86, 0x4A, 0x00, 0x00, 0x00 };
  23. networkInterface.EnableStaticIP("192.168.0.119", "255.255.255.0", "192.168.0.1");
  24. Random rnd = new Random(10);
  25. IPHostEntry hostEntry = Dns.GetHostEntry("192.168.0.100");
  26. Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  27. socket.Connect(new IPEndPoint(hostEntry.AddressList[0], 8080));
  28. Byte[] bytesToSend = Encoding.UTF8.GetBytes(rnd.Next(100).ToString());
  29. socket.Send(bytesToSend, bytesToSend.Length, 0);
  30. socket.Close();
  31. bytesToSend = Encoding.UTF8.GetBytes(rnd.Next(100).ToString());
  32. socket.Connect(new IPEndPoint(hostEntry.AddressList[0], 8080));
  33. socket.Send(bytesToSend, bytesToSend.Length, 0);
  34. socket.Close();
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement