//제어요청 핸들러 void SetupServer_RecvRcInfo(object sender, RecvRCInfoEventArgs e) { if (RecvedRCInfo != null) //구독자가 있을때 { RecvedRCInfo(this, e); } }
void Remote_RecvedRCInfo(object sender, RecvRCInfoEventArgs e) { if (this.InvokeRequired) { object[] objs = new object[2] { sender, e }; this.Invoke(new Remote_Dele(Remote_RecvedRCInfo), objs); } else { tbx_cont_ip.Text = e.IPAddressStr; //요청주소 표시 sIp = e.IPAddressStr; sPort = e.Port; btn_ok.Enabled = true; //자동연결로 변경 btn_ok_Click(sender, e); } }
//연결요청 대기 static void AcceptLoop() { try { while (true) { Socket do_sock = listener.Accept(); //리스너 연결 수락 if (RecvRcInfo != null) //수신 이벤트 핸들러가 있으면 == 받은게 있으면 { RecvRCInfoEventArgs e = new RecvRCInfoEventArgs(do_sock.RemoteEndPoint); RecvRcInfo(null, e); } } } catch { Close(); } }