Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- using System.Net.Sockets;
- using System.Text;
- using System.Threading;
- using Microsoft.SPOT;
- using Microsoft.SPOT.Hardware;
- using Microsoft.SPOT.Net.NetworkInformation;
- using SecretLabs.NETMF.Hardware;
- using SecretLabs.NETMF.Hardware.Netduino;
- namespace wiznetTeste
- {
- public class Program
- {
- public static void Main()
- {
- SecretLabs.NETMF.Net.Wiznet5100 wiznet = new SecretLabs.NETMF.Net.Wiznet5100(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10);
- NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];
- networkInterface.PhysicalAddress = new byte[] { 0x5C, 0x86, 0x4A, 0x00, 0x00, 0x00 };
- networkInterface.EnableStaticIP("192.168.0.119", "255.255.255.0", "192.168.0.1");
- Random rnd = new Random(10);
- IPHostEntry hostEntry = Dns.GetHostEntry("192.168.0.100");
- Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
- socket.Connect(new IPEndPoint(hostEntry.AddressList[0], 8080));
- Byte[] bytesToSend = Encoding.UTF8.GetBytes(rnd.Next(100).ToString());
- socket.Send(bytesToSend, bytesToSend.Length, 0);
- socket.Close();
- bytesToSend = Encoding.UTF8.GetBytes(rnd.Next(100).ToString());
- socket.Connect(new IPEndPoint(hostEntry.AddressList[0], 8080));
- socket.Send(bytesToSend, bytesToSend.Length, 0);
- socket.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement