做网站还需要兼容ie8吗,wordpress 单栏 宽屏,永久免费自动建站,一个网站的建设步骤当前位置:我的异常网 网络通信 UDP组播#xff0c;完成端口#xff0c;双网卡收不到数据#xff1f;帮帮忙UDP组播#xff0c;完成端口#xff0c;双网卡收不到数据#xff1f;帮帮忙www.myexceptions.net 网友分享于#xff1a;2013-04-13 浏览#xff1a;848次UDP…当前位置:我的异常网» 网络通信 » UDP组播完成端口双网卡收不到数据帮帮忙UDP组播完成端口双网卡收不到数据帮帮忙www.myexceptions.net 网友分享于2013-04-13 浏览848次UDP组播完成端口双网卡收不到数据各位大哥帮帮忙各位大哥小弟我写了一个网络通信程序通过完成端口在指定的网卡上接收网络上传输过来的语音数据现在情况是1各主机均配置了两张网卡其中一张网卡由该程序使用另一张网卡其他程序在用2程序在大部分客户端上运行都正常唯独在其中一个客户端上GetQueuedCompletionStatus该函数不返回若该客户端把另一张网卡的网线拔掉或者禁用掉该网卡启动软件工作正常。在工作过程中插上另一张网卡的网线也没有问题。但是如果在程序启动前两张网卡都在工作则GetQueuedCompletionStatus不返回。主要代码如下调用Create函数的代码m_Receive.Create(uLocalPort,lpDstStr,0, lpBindAddr)uLocalPort组播端口lpDstStr组播地址lpBindAddr本机上要绑定的网卡地址bool CUdpSocket::Create(USHORT uLocalPort,LPCTSTR lpDstAddr,USHORT uDstPort,LPCTSTR lpBindAddr/*NULL*/){if ( htons(uLocalPort) m_stLclAddr.sin_port m_stDstAddr.sin_addr.s_addr inet_addr(lpDstAddr) m_stDstAddr.sin_port htons(uDstPort)){return true ;}//*/if (!CreateSocket(uLocalPort,lpBindAddr))return false ;/* Assign our destination address */m_stDstAddr.sin_family AF_INET;m_stDstAddr.sin_addr.s_addr inet_addr(lpDstAddr);m_stDstAddr.sin_port htons(uDstPort);//广播if(strstr(lpDstAddr,255)){BOOL bEnable TRUE ;int nRes setsockopt(m_socket,SOL_SOCKET,SO_BROADCAST,(const char*)bEnable,sizeof(bEnable));}//else{// note the 2 says how many concurrent cpu bound threads to allow thru// this should be tunable based on the requests. CPU bound requests will// really really honor this.//JoinMultiCastGroup(lpDstAddr,uDstPort);}//* Disable loopback *///*/BOOL fFlag FALSE;int nRet setsockopt(m_socket,IPPROTO_IP,IP_MULTICAST_LOOP,(char *)fFlag,sizeof(fFlag));if (nRet SOCKET_ERROR) {printf (setsockopt() IP_MULTICAST_LOOP failed, Err: %d\n,WSAGetLastError());return false ;}//*///return CreateCompleteIO();}bool CUdpSocket::JoinMultiCastGroup(LPCTSTR lpDstAddr, USHORT uDstPort){/* Assign our destination address */m_stDstAddr.sin_family AF_INET;m_stDstAddr.sin_addr.s_addr inet_addr(lpDstAddr);m_stDstAddr.sin_port htons(uDstPort);struct ip_mreq stMreq; /* Multicast interface structure *//* Join the multicast group** NOTE: According to RFC 1112, a sender does not need to join the* group, however Microsoft requires a socket to join a group in* order to use setsockopt() IP_MULTICAST_TTL (or fails with error* WSAEINVAL).*/stMreq.imr_multiaddr.s_addr inet_addr(lpDstAddr);stMreq.imr_interface.s_addr INADDR_ANY;int nRet setsockopt(m_socket,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char *)stMreq,sizeof(stMreq));if (nRet SOCKET_ERROR) {printf (setsockopt() IP_ADD_MEMBERSHIP address %s failed, Err: %d\n,lpDstAddr, WSAGetLastError());return false ;}/* Set IP TTL to traverse up to multiple routers *///*u_long lTTL 2 ;nRet setsockopt(m_socket,IPPROTO_IP,IP_MULTICAST_TTL,(char *)lTTL,sizeof(lTTL));if (nRet SOCKET_ERROR) {printf (setsockopt() IP_MULTICAST_TTL failed, Err: %d\n,WSAGetLastError());}//*/return true ;}//bool CUdpSocket::CreateCompleteIO(){m_hCompletionPort CreateIoCompletionPort (INVALID_HANDLE_VALUE,NULL,0,1);if (!m_hCompletionPort){printf (m_hCompletionPort Create Failed\n);return false;}//Associate this socket to this I/O completion port文章评论