Esempio n. 1
0
        public void Disconnect()
        {
            //格式:主机IP地址,所在地区,主机名,用户名,操作系统,cpu,内存,硬盘,显示器,视频,状态
            StringBuilder mesBuilder = new StringBuilder();

            mesBuilder.Append(LocalAddress + ",");
            mesBuilder.Append(HostInfo.Location() + ",");
            mesBuilder.Append(HostInfo.HostName() + ",");
            mesBuilder.Append(HostInfo.UserName() + ",");
            mesBuilder.Append(HostInfo.OSName() + ",");
            mesBuilder.Append(HostInfo.CPUType() + ",");
            mesBuilder.Append(HostInfo.MemorySize() + ",");
            mesBuilder.Append(HostInfo.HardDiskSize() + ",");
            mesBuilder.Append(HostInfo.ScreenSize() + ",");
            mesBuilder.Append(HostInfo.VideoStatus() + ",");
            mesBuilder.Append("断开,");

            message = mesBuilder.ToString();

            byte[] data = Encoding.Unicode.GetBytes(message);
            socket.SendTo(data, ipEndPoint);



            thread.Abort();
            socket.Close();
        }
Esempio n. 2
0
        private void Connect()
        {
            //格式:主机IP地址,所在地区,主机名,用户名,操作系统,cpu,内存,硬盘,显示器,视频,状态(连接、断开)
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(LocalAddress + ",");
            stringBuilder.Append(HostInfo.Location() + ",");
            stringBuilder.Append(HostInfo.HostName() + ",");
            stringBuilder.Append(HostInfo.UserName() + ",");
            stringBuilder.Append(HostInfo.OSName() + ",");
            stringBuilder.Append(HostInfo.CPUType() + ",");
            stringBuilder.Append(HostInfo.MemorySize() + ",");
            stringBuilder.Append(HostInfo.HardDiskSize() + ",");
            stringBuilder.Append(HostInfo.ScreenSize() + ",");
            stringBuilder.Append(HostInfo.VideoStatus() + ",");
            stringBuilder.Append(HostInfo.ConnectStatus() + ",");

            message = stringBuilder.ToString();

            byte[] data = Encoding.Unicode.GetBytes(message);

            while (true)
            {
                socket.SendTo(data, ipEndPoint);

                //每五秒钟向局域网广播一次
                Thread.Sleep(5000);
            }
        }