b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

udp的广播_setsockopt广播_udp组播(2)

电脑杂谈  发布时间:2017-04-28 05:12:18  来源:网络整理

m_Socket=socket(AF_INET,SOCK_DGRAM,0);

// if(SOCKET_ERROR==bind(m_Socket,(structsockaddr*)&m_ServerAddr,sizeof(m_ServerAddr)))

// {

// returnfalse;

setsockopt广播_udp组播_udp的广播

// }

returntrue;

}

boolCUDPClient::Receive(char*szReceive,DWORDdwReceiveSize)

{

//非阻塞消息select使用

fd_setfdread;

//初始化fd_set

FD_ZERO(&fdread);

//分配套接字句柄到相应的fd_set

FD_SET(m_Socket,&fdread);

select(0,&fdread,NULL,NULL,&m_tv);

if(FD_ISSET(m_Socket,&fdread))

{

intlen=sizeof(m_ServerAddr);

if(SOCKET_ERROR==recvfrom(m_Socket,szReceive,dwReceiveSize,0,

(structsockaddr*)&m_ServerAddr,&len))

{

returnfalse;

}

unsignedshort*pUnBuff=(unsignedshort*)szReceive;

cout<<"CUDPClient::Receive:"<<inet_ntoa(m_ServerAddr.sin_addr)<<"-"<<pUnBuff[0]<<"-"<<pUnBuff[1]<<endl;

}

returntrue;

}


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/shumachanpin/article-43924-2.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...