public ShowForm(deviceInfo info) { InitializeComponent(); if (info.type == netType.TCP) { Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { idasEp = new IPEndPoint(IPAddress.Parse(info.ip), int.Parse(info.port)); } catch { MessageBox.Show("IP地址错误"); return; } socket.Connect(idasEp); c = new communication(socket); c.opdh += new onPictureDataHandler(getPictureDate); } else { //ipep = new IPEndPoint(IPAddress.Any, int.Parse(port)); //Socket udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //udpSocket.Bind(ipep); cUdp = new communicationUdp(info.ip, int.Parse(info.port)); cUdp.opdh += new onPictureDataHandler(getPictureDate); } this.label2.Text = info.ip; this.label4.Text = "" + info.port; //this.progressBar1.Value = 100; }
void acceptThread() { while (true) { clskt = srskt.Accept(); if (clskt != null) { #if true communication c = new communication(clskt, index); c.opdh += new onPictureDataHandler(onGetPicture); index++; cList.Add(c); #else if (occ != null) { occ(clskt); } #endif } } }