1个回答
2017-09-14
展开全部
voidCUdp2Dlg::OnUDPClient(){//建立客户端套接字,并发送,目的获取网络时间CStringstrsend,strrece;strsend="0130000000000";m_sockrecv.Create(123,SOCK_DGRAM,"129.6.15.28");m_sockrecv.Bind(123,"129.6.15.28");m_sockrecv.SendTo(strsend,64,123,"129.6.15.28",0);SetTimer(1,3000,NULL);}voidCUdp2Dlg::OnTimer(UINTnIDEvent){//建立定时器,接受时间charstrrece[1024];UINTuport=123;CStringstrip="129.6.15.28";intirecv=m_sockrecv.ReceiveFrom(strrece,1025,strip,uport,0);//strrece[irecv]='\0';if(irecv!=SOCKET_ERROR){strrece[irecv]=NULL;m_editrecv=strrece;UpdateData(FALSE);}CDialog::OnTimer(nIDEvent);}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询