예제 #1
0
bool NetSocket::LeaveGroup(NetAddress *group)
{
	ip_mreq mreq;
	SIN_SET_ADDR(&mreq.imr_multiaddr, *(unsigned int *)&group->m_IP[0]);
	SIN_SET_ADDR(&mreq.imr_interface, 0);

	if (setsockopt(m_Socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, (char *)&mreq, sizeof(mreq)) == SOCKET_ERROR)
	{
		int err = m_Network->GetLastErrorCode();
		if (err != WSAEAFNOSUPPORT) {
			m_System->DPrintf("WARNING! NetSocket::LeaveGroup: IP_DROP_MEMBERSHIP: %s\n", m_Network->GetErrorText(err));
		}

		return false;
	}

	return true;
}
예제 #2
0
파일: net_ws.cpp 프로젝트: omertelli/rehlds
/* <d4d51> ../engine/net_ws.c:2504 */
qboolean NET_LeaveGroup(netsrc_t sock, netadr_t& addr)
{
	ip_mreq mreq;
	int net_socket = ip_sockets[sock];
	SIN_SET_ADDR(&mreq.imr_multiaddr, *(unsigned int*)&addr.ip[0]);
	SIN_SET_ADDR(&mreq.imr_interface, 0);

	if (CRehldsPlatformHolder::get()->setsockopt(net_socket, 0, 6, (char *)&mreq, sizeof(mreq)) != SOCKET_ERROR)
	{
#ifdef _WIN32
		int err = WSAGetLastError();
		if (err != WSAEAFNOSUPPORT)
#else
		int err = errno;
		if (err != EAFNOSUPPORT)
#endif // _WIN32
		{
			return FALSE;
		}
	}

	return TRUE;
}
예제 #3
0
파일: net_ws.cpp 프로젝트: omertelli/rehlds
/* <d4ccb> ../engine/net_ws.c:2470 */
qboolean NET_JoinGroup(netsrc_t sock, netadr_t& addr)
{
	ip_mreq mreq;
	int net_socket = ip_sockets[sock];
	SIN_SET_ADDR(&mreq.imr_multiaddr, *(unsigned int*)&addr.ip[0]);
	SIN_SET_ADDR(&mreq.imr_interface, 0);

	if (CRehldsPlatformHolder::get()->setsockopt(net_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*)&mreq, sizeof(mreq)) == SOCKET_ERROR)
	{
#ifdef _WIN32
		int err = WSAGetLastError();
		if (err != WSAEAFNOSUPPORT)
#else
		int err = errno;
		if (err != EAFNOSUPPORT)
#endif // _WIN32
		{
			Con_Printf("WARNING: NET_JoinGroup: IP_ADD_MEMBERSHIP: %s", NET_ErrorString(err));
		}
		return FALSE;
	}

	return TRUE;
}