自己写的调用飞鸽传书

private static void SendMsg()
        {
            //主机名称
            string hostName = Dns.GetHostName();
            //要发送的人的名称
            string sendTo = "zhangdongyan";
            //端口
            int port = 2425;

            //存放发送消息的字节数组
            byte[] msgContent = null;

            string msg = "1:" + DateTime.Now.ToFileTime() + ":" + sendTo + ":" + hostName + ":" + "32:" + "这个是测试的!";

            string msg1 = "1:1273050382:Administrator:"+Dns.GetHostName()+":zhangdongyan:192.168.0.66:fsdfsdfsf";
            msgContent = Encoding.Default.GetBytes(msg);

            Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
                ProtocolType.Udp);

            sock.SetSocketOption(SocketOptionLevel.Socket,
              SocketOptionName.Broadcast, 1);

            IPEndPoint iep1 = new IPEndPoint(IPAddress.Any, 2425);//255.255.255.255
            IPEndPoint iep2 = new IPEndPoint(IPAddress.Parse("192.168.0.133"),2425);
            //sock.SendTo(msgContent,iep1);
            sock.SendTo(msgContent, iep2);
            sock.Close();

        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值