日期:2014-05-17 浏览次数:21133 次
/// <summary>
/// 模拟发送端口5860
/// </summary>
private void send5860()
{
try
{
Console.WriteLine("This is a Server, host name is {0}", Dns.GetHostName());
Socket socks = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);//New一个Socket配置连接方式
//socks.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 900); //设置响应时间
IPEndPoint iep1 = new IPEndPoint(IPAddress.Broadcast, 5860);
while (true)
{
Console.WriteLine("5860 Success" + " port:5860");
byte[] data = System.Text.Encoding.UTF8.GetBytes("5860 已经成功"); //将字符转化为可传输的格式
socks.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);
socks.SendTo(data, iep1);
//socks.SendTo(data, iep2);
Thread.Sleep(500);
}
}
catch(Exception ex)
{