Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Net;
- using System.Net.Sockets;
- namespace TCPIP_TEST
- {
- class Program
- {
- static void Main(string[] args)
- {
- byte[] ip = { 192, 168, 0, 16 };
- IPAddress addr = new IPAddress(ip);
- IPEndPoint point = new IPEndPoint(addr, (4950));
- byte[] dataarray = { 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- Send(dataarray, point);
- System.Threading.Thread.Sleep(10000);
- }
- public static void Send(byte[] rawData, IPEndPoint target)
- {
- // change what you pass to this constructor to your needs
- Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
- try
- {
- s.SendBufferSize = 20;
- s.Connect(target);
- s.Send(rawData);
- if (s.Connected) { Console.WriteLine("Connected succesfully"); }else
- {
- Console.WriteLine("Could not connect to target address");
- }
- for (int i =0; i<1000; i++)
- {
- s.Send(rawData);
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("An exception of type " + ex.ToString() + " has occured");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement