标签:data .so point while .text text etop ogr int
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace ConsoleApp4
{
class Program
{
static void Main(string[] args)
{
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint iep1 = new IPEndPoint(IPAddress.Broadcast, 8093);
IPEndPoint iep2 = new IPEndPoint(IPAddress.Parse("192.168.31.255"), 9001);
string hostname = Dns.GetHostName();
byte[] data = Encoding.ASCII.GetBytes(hostname);
sock.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.Broadcast, 1);
Thread thread1 = new Thread(send);
Thread thread2 = new Thread(send);
Thread thread3 = new Thread(send);
Thread thread4 = new Thread(send);
Thread thread5 = new Thread(send);
Thread thread6 = new Thread(send);
thread1.Start();
thread2.Start();
thread3.Start();
thread4.Start();
thread5.Start();
thread6.Start();
void send() {
while (true)
{
sock.SendTo(data, iep1);
sock.SendTo(data, iep2);
}
}
}
}
}
标签:data .so point while .text text etop ogr int
原文地址:http://www.cnblogs.com/zhuzhengchao2017/p/7591458.html