• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ NET_ErrorString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NET_ErrorString函数的典型用法代码示例。如果您正苦于以下问题:C++ NET_ErrorString函数的具体用法?C++ NET_ErrorString怎么用?C++ NET_ErrorString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NET_ErrorString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: SV_SendClientsFragments

/*
* SV_SendClientsFragments
*/
bool SV_SendClientsFragments( void )
{
	client_t *client;
	int i;
	bool sent = false;

	// send a message to each connected client
	for( i = 0, client = svs.clients; i < sv_maxclients->integer; i++, client++ )
	{
		if( client->state == CS_FREE || client->state == CS_ZOMBIE )
			continue;
		if( client->edict && ( client->edict->r.svflags & SVF_FAKECLIENT ) )
			continue;
		if( !client->netchan.unsentFragments )
			continue;

		if( !Netchan_TransmitNextFragment( &client->netchan ) )
		{
			Com_Printf( "Error sending fragment to %s: %s\n", NET_AddressToString( &client->netchan.remoteAddress ),
				NET_ErrorString() );
			if( client->reliable )
				SV_DropClient( client, DROP_TYPE_GENERAL, "Error sending fragment: %s\n", NET_ErrorString() );
			continue;
		}

		sent = true;
	}

	return sent;
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:33,代码来源:sv_send.c


示例2: TV_Relay_SendClientMessages

/*
* TV_Relay_SendClientMessages
*/
void TV_Relay_SendClientMessages( relay_t *relay )
{
	int i;
	client_t *client;

	assert( relay );

	// send a message to each connected client
	for( i = 0, client = tvs.clients; i < tv_maxclients->integer; i++, client++ )
	{
		if( client->state != CS_SPAWNED )
			continue;
		if( client->relay != relay )
			continue;

		if( !TV_Relay_SendClientDatagram( relay, client ) )
		{
			Com_Printf( "%s" S_COLOR_WHITE ": Error sending message: %s\n", client->name, NET_ErrorString() );
			if( client->reliable )
			{
				TV_Downstream_DropClient( client, DROP_TYPE_GENERAL, "Error sending message: %s\n",
					NET_ErrorString() );
			}
		}
	}
}
开发者ID:Kaperstone,项目名称:warsow,代码行数:29,代码来源:tv_relay_client.c


示例3: TV_Downstream_SendClientsFragments

/*
* TV_Downstream_SendClientsFragments
*/
qboolean TV_Downstream_SendClientsFragments( void )
{
	client_t *client;
	int i;
	qboolean remaining = qfalse;

	// send a message to each connected client
	for( i = 0, client = tvs.clients; i < tv_maxclients->integer; i++, client++ )
	{
		if( client->state == CS_FREE || client->state == CS_ZOMBIE )
			continue;

		if( !client->netchan.unsentFragments )
			continue;

		if( !Netchan_TransmitNextFragment( &client->netchan ) )
		{
			Com_Printf( "%s" S_COLOR_WHITE ": Error sending fragment: %s\n", client->name, NET_ErrorString() );
			if( client->reliable )
			{
				TV_Downstream_DropClient( client, DROP_TYPE_GENERAL, "Error sending fragment: %s\n",
					NET_ErrorString() );
			}
			continue;
		}

		if( client->netchan.unsentFragments )
			remaining = qtrue;
	}

	return remaining;
}
开发者ID:Kaperstone,项目名称:warsow,代码行数:35,代码来源:tv_downstream.c


示例4: NET_IPSocket

/*
====================
NET_Socket
====================
*/
int NET_IPSocket (char *net_interface, int port)
{
	int newsocket = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
	if (newsocket == -1)
	{
		Com_Printf ("UDP_OpenSocket: Couldn't make socket: %s\n", LOG_NET, NET_ErrorString());
		return 0;
	}

	if (newsocket >= FD_SETSIZE)
		Com_Error (ERR_FATAL, "NET_IPSocket: socket is higher than FD_SETSIZE");

	// make it non-blocking
	qboolean _true = true;
	if (ioctl (newsocket, FIONBIO, &_true) == -1)
	{
		Com_Printf ("UDP_OpenSocket: Couldn't make non-blocking: %s\n", LOG_NET, NET_ErrorString());
		return 0;
	}

	// make it broadcast capable
	int	i = 1;
	if (setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i)) == -1)
	{
		Com_Printf ("UDP_OpenSocket: Couldn't set SO_BROADCAST: %s\n", LOG_NET, NET_ErrorString());
		return 0;
	}

	// r1: accept icmp unreachables for quick disconnects
	if (!net_no_recverr->intvalue)
	{
		if (setsockopt (newsocket, IPPROTO_IP, IP_RECVERR, (char *)&i, sizeof(i)) == -1)
		{
			Com_Printf ("UDP_OpenSocket: Couldn't set IP_RECVERR: %s\n", LOG_NET, NET_ErrorString());
		}
	}

	struct sockaddr_in address;
	if (!net_interface || !net_interface[0] || !Q_stricmp(net_interface, "localhost"))
		address.sin_addr.s_addr = INADDR_ANY;
	else
		NET_StringToSockaddr (net_interface, (struct sockaddr *)&address);

	if (port == PORT_ANY)
		address.sin_port = 0;
	else
		address.sin_port = htons((uint16)port);

	address.sin_family = AF_INET;

	if( bind (newsocket, (struct sockaddr *) &address, sizeof(address)) == -1)
	{
		close (newsocket);
		Com_Printf ("UDP_OpenSocket: Couldn't bind to UDP port %d: %s\n", LOG_NET, port, NET_ErrorString());
		return 0;
	}

	return newsocket;
}
开发者ID:turol,项目名称:webquake2,代码行数:64,代码来源:net_udp.c


示例5: NET_IPSocket

/*
====================
NET_IPSocket
====================
*/
int NET_IPSocket( char *net_interface, int port ) {
	SOCKET newsocket;
	struct sockaddr_in address;
//bani - was improper parameter
	unsigned long _true = qtrue;
	int i = 1;
	int err;

	if ( net_interface ) {
		Com_Printf( "Opening IP socket: %s:%i\n", net_interface, port );
	} else {
		Com_Printf( "Opening IP socket: localhost:%i\n", port );
	}

	if ( ( newsocket = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ) ) == INVALID_SOCKET ) {
		err = WSAGetLastError();
		if ( err != WSAEAFNOSUPPORT ) {
			Com_Printf( "WARNING: UDP_OpenSocket: socket: %s\n", NET_ErrorString() );
		}
		return 0;
	}

	// make it non-blocking
	if ( ioctlsocket( newsocket, FIONBIO, &_true ) == SOCKET_ERROR ) {
		Com_Printf( "WARNING: UDP_OpenSocket: ioctl FIONBIO: %s\n", NET_ErrorString() );
		return 0;
	}

	// make it broadcast capable
	if ( setsockopt( newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof( i ) ) == SOCKET_ERROR ) {
		Com_Printf( "WARNING: UDP_OpenSocket: setsockopt SO_BROADCAST: %s\n", NET_ErrorString() );
		return 0;
	}

	if ( !net_interface || !net_interface[0] || !Q_stricmp( net_interface, "localhost" ) ) {
		address.sin_addr.s_addr = INADDR_ANY;
	} else {
		Sys_StringToSockaddr( net_interface, (struct sockaddr *)&address );
	}

	if ( port == PORT_ANY ) {
		address.sin_port = 0;
	} else {
		address.sin_port = htons( (short)port );
	}

	address.sin_family = AF_INET;

	if ( bind( newsocket, (void *)&address, sizeof( address ) ) == SOCKET_ERROR ) {
		Com_Printf( "WARNING: UDP_OpenSocket: bind: %s\n", NET_ErrorString() );
		closesocket( newsocket );
		return 0;
	}

	//bani
	NET_GetInterfaces();

	return newsocket;
}
开发者ID:AdrienJaguenet,项目名称:Enemy-Territory,代码行数:64,代码来源:win_net.c


示例6: NET_UDPSocket

/*
 ==================
 NET_UDPSocket
 ==================
*/
static bool NET_UDPSocket (netSrc_t sock, const char *ip, int port){

	struct sockaddr_in	adr;
	ulong				value = 1;

	Com_DPrintf("NET_UDPSocket( %s, %i )\n", ip, port);

	// Open an UDP socket
	if ((net.sockets[sock] = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET){
		Com_DPrintf(S_COLOR_YELLOW "NET_OpenSocket: socket() = %s\n", NET_ErrorString());
		return false;
	}

	// Make it non-blocking
	if (ioctlsocket(net.sockets[sock], FIONBIO, &value) == SOCKET_ERROR){
		Com_DPrintf(S_COLOR_YELLOW "NET_OpenSocket: ioctlsocket() = %s\n", NET_ErrorString());

		closesocket(net.sockets[sock]);
		net.sockets[sock] = INVALID_SOCKET;

		return false;
	}

	// Make it broadcast capable
	if (setsockopt(net.sockets[sock], SOL_SOCKET, SO_BROADCAST, (const char *)&value, sizeof(value)) == SOCKET_ERROR){
		Com_DPrintf(S_COLOR_YELLOW "NET_OpenSocket: setsockopt() = %s\n", NET_ErrorString());

		closesocket(net.sockets[sock]);
		net.sockets[sock] = INVALID_SOCKET;

		return false;
	}

	// Bind it
	adr.sin_family = AF_INET;

	if (!Str_ICompare(ip, "localhost"))
		adr.sin_addr.s_addr = INADDR_ANY;
	else {
		if (!NET_StringToSockAdr(ip, (struct sockaddr *)&adr))
			adr.sin_addr.s_addr = INADDR_ANY;
	}

	if (port == 0)
		adr.sin_port = 0;
	else
		adr.sin_port = htons((ushort)port);

	if (bind(net.sockets[sock], (void *)&adr, sizeof(adr)) == SOCKET_ERROR){
		Com_DPrintf(S_COLOR_YELLOW "NET_OpenSocket: bind() = %s\n", NET_ErrorString());

		closesocket(net.sockets[sock]);
		net.sockets[sock] = INVALID_SOCKET;

		return false;
	}

	return true;
}
开发者ID:Mirrorman95,项目名称:quake-2-evolved,代码行数:64,代码来源:win_network.c


示例7: NET_IPXSocket

int
NET_IPXSocket(int port)
{
	int newsocket;
	struct sockaddr_ipx address;
	unsigned long t = 1;

	if ((newsocket = socket(PF_IPX, SOCK_DGRAM, NSPROTO_IPX)) == -1)
	{
		int err;

		err = WSAGetLastError();

		if (err != WSAEAFNOSUPPORT)
		{
			Com_Printf("WARNING: IPX_Socket: socket: %s\n", NET_ErrorString());
		}

		return 0;
	}

	/* make it non-blocking */
	if (ioctlsocket(newsocket, FIONBIO, &t) == -1)
	{
		Com_Printf("WARNING: IPX_Socket: ioctl FIONBIO: %s\n", NET_ErrorString());
		return 0;
	}

	/* make it broadcast capable */
	if (setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&t,
				sizeof(t)) == -1)
	{
		Com_Printf("WARNING: IPX_Socket: setsockopt SO_BROADCAST: %s\n",
				NET_ErrorString());
		return 0;
	}

	address.sa_family = AF_IPX;
	memset(address.sa_netnum, 0, 4);
	memset(address.sa_nodenum, 0, 6);

	if (port == PORT_ANY)
	{
		address.sa_socket = 0;
	}
	else
	{
		address.sa_socket = htons((short)port);
	}

	if (bind(newsocket, (void *)&address, sizeof(address)) == -1)
	{
		Com_Printf("WARNING: IPX_Socket: bind: %s\n", NET_ErrorString());
		closesocket(newsocket);
		return 0;
	}

	return newsocket;
}
开发者ID:Pickle,项目名称:yquake2,代码行数:59,代码来源:network.c


示例8: NET_IPSocket

/*
====================
NET_IPSocket
====================
 */
int NET_IPSocket(char *net_interface, int port, int *err) {
    SOCKET newsocket;
    struct sockaddr_in address;
    u_long _true = 1;
    int i = 1;

    *err = 0;

    if (net_interface) {
        Com_Printf("Opening IP socket: %s:%i\n", net_interface, port);
    } else {
        Com_Printf("Opening IP socket: 0.0.0.0:%i\n", port);
    }

    if ((newsocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
        *err = socketError;
        Com_Printf("WARNING: NET_IPSocket: socket: %s\n", NET_ErrorString());
        return newsocket;
    }
    // make it non-blocking
    if (ioctlsocket(newsocket, FIONBIO, &_true) == SOCKET_ERROR) {
        Com_Printf("WARNING: NET_IPSocket: ioctl FIONBIO: %s\n", NET_ErrorString());
        *err = socketError;
        closesocket(newsocket);
        return INVALID_SOCKET;
    }

    // make it broadcast capable
    if (setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *) & i, sizeof (i)) == SOCKET_ERROR) {
        Com_Printf("WARNING: NET_IPSocket: setsockopt SO_BROADCAST: %s\n", NET_ErrorString());
    }

    if (!net_interface || !net_interface[0]) {
        address.sin_family = AF_INET;
        address.sin_addr.s_addr = INADDR_ANY;
    } else {
        if (!Sys_StringToSockaddr(net_interface, (struct sockaddr *) & address, sizeof (address), AF_INET)) {
            closesocket(newsocket);
            return INVALID_SOCKET;
        }
    }

    if (port == PORT_ANY) {
        address.sin_port = 0;
    } else {
        address.sin_port = htons((short) port);
    }

    if (bind(newsocket, (void *) & address, sizeof (address)) == SOCKET_ERROR) {
        Com_Printf("WARNING: NET_IPSocket: bind: %s\n", NET_ErrorString());
        *err = socketError;
        closesocket(newsocket);
        return INVALID_SOCKET;
    }

    return newsocket;
}
开发者ID:zturtleman,项目名称:q3rain,代码行数:62,代码来源:net_ip.c


示例9: NET_IPSocket

SOCKET NET_IPSocket( const char *net_interface, int port ) {
	SOCKET				newsocket;
	struct sockaddr_in	address;
	u_long			    _true = 1;
	int					i = 1;

	if( !net_interface || !net_interface[0] ) {
		net_interface = "localhost";
	}

	Com_Printf( "Opening IP socket: %s:%i\n", net_interface, port );

	if( ( newsocket = socket( PF_INET, SOCK_DGRAM, IPPROTO_UDP ) ) == INVALID_SOCKET ) {
#ifdef _WIN32
		if( WSAGetLastError() != WSAEAFNOSUPPORT )
#endif
			Com_Printf ("WARNING: UDP_OpenSocket: socket: %s", NET_ErrorString() );
		return INVALID_SOCKET;
	}

	// make it non-blocking
	if( ioctlsocket( newsocket, FIONBIO, &_true ) == SOCKET_ERROR ) {
		Com_Printf ("WARNING: UDP_OpenSocket: ioctl FIONBIO: %s\n", NET_ErrorString() );
		closesocket( newsocket );
		return INVALID_SOCKET;
	}

	// make it broadcast capable
	if( setsockopt( newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof( i ) ) == SOCKET_ERROR ) {
		Com_Printf ("WARNING: UDP_OpenSocket: setsockopt SO_BROADCAST: %s\n", NET_ErrorString() );
		closesocket( newsocket );
		return INVALID_SOCKET;
	}

	if( !Q_stricmp( net_interface, "localhost" ) ) {
		address.sin_addr.s_addr = INADDR_ANY;
	} else {
		NET_StringToSockaddr( net_interface, (struct sockaddr *)&address );
	}

	if( port == PORT_ANY ) {
		address.sin_port = 0;
	} else {
		address.sin_port = htons( (u_short)port );
	}

	address.sin_family = AF_INET;

	if( bind( newsocket, (void *)&address, sizeof( address ) ) == SOCKET_ERROR ) {
		Com_Printf ("WARNING: UDP_OpenSocket: bind: %s\n", NET_ErrorString() );
		closesocket( newsocket );
		return INVALID_SOCKET;
	}

	return newsocket;
}
开发者ID:chrisnew,项目名称:quake2,代码行数:56,代码来源:net.c


示例10: NET_IPXSocket

/*
====================
NET_IPXSocket
====================
*/
int NET_IPXSocket(int port)
{
	SOCKET          newsocket;
	struct sockaddr_ipx address;

//bani - was improper parameter
	unsigned long   _true = qtrue;
	int             err;

	if((newsocket = socket(AF_IPX, SOCK_DGRAM, NSPROTO_IPX)) == INVALID_SOCKET)
	{
		err = WSAGetLastError();
		if(err != WSAEAFNOSUPPORT)
		{
			Com_Printf("WARNING: IPX_Socket: socket: %s\n", NET_ErrorString());
		}
		return 0;
	}

	// make it non-blocking
	if(ioctlsocket(newsocket, FIONBIO, &_true) == SOCKET_ERROR)
	{
		Com_Printf("WARNING: IPX_Socket: ioctl FIONBIO: %s\n", NET_ErrorString());
		return 0;
	}

	// make it broadcast capable
	if(setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&_true, sizeof(_true)) == SOCKET_ERROR)
	{
		Com_Printf("WARNING: IPX_Socket: setsockopt SO_BROADCAST: %s\n", NET_ErrorString());
		return 0;
	}

	address.sa_family = AF_IPX;
	memset(address.sa_netnum, 0, 4);
	memset(address.sa_nodenum, 0, 6);
	if(port == PORT_ANY)
	{
		address.sa_socket = 0;
	}
	else
	{
		address.sa_socket = htons((short)port);
	}

	if(bind(newsocket, (void *)&address, sizeof(address)) == SOCKET_ERROR)
	{
		Com_Printf("WARNING: IPX_Socket: bind: %s\n", NET_ErrorString());
		closesocket(newsocket);
		return 0;
	}

	return newsocket;
}
开发者ID:ethr,项目名称:ETXrealPro,代码行数:59,代码来源:win_net.c


示例11: SV_SendClientMessages

/*
* SV_SendClientMessages
*/
void SV_SendClientMessages( void )
{
	int i;
	client_t *client;

	// send a message to each connected client
	for( i = 0, client = svs.clients; i < sv_maxclients->integer; i++, client++ )
	{
		if( client->state == CS_FREE || client->state == CS_ZOMBIE )
			continue;

		if( client->edict && ( client->edict->r.svflags & SVF_FAKECLIENT ) )
		{
			client->lastSentFrameNum = sv.framenum;
			continue;
		}

		if( !client->tvclient ) {
			SV_UpdateActivity();
		}

		if( client->state == CS_SPAWNED )
		{
			if( !SV_SendClientDatagram( client ) )
			{
				Com_Printf( "Error sending message to %s: %s\n", client->name, NET_ErrorString() );
				if( client->reliable )
				{
					SV_DropClient( client, DROP_TYPE_GENERAL, "Error sending message: %s\n", NET_ErrorString() );
				}
			}
		}
		else
		{
			// send pending reliable commands, or send heartbeats for not timing out
			if( client->reliableSequence > client->reliableAcknowledge ||
				svs.realtime - client->lastPacketSentTime > 1000 )
			{
				SV_InitClientMessage( client, &tmpMessage, NULL, 0 );
				SV_AddReliableCommandsToMessage( client, &tmpMessage );
				if( !SV_SendMessageToClient( client, &tmpMessage ) )
				{
					Com_Printf( "Error sending message to %s: %s\n", client->name, NET_ErrorString() );
					if( client->reliable )
					{
						SV_DropClient( client, DROP_TYPE_GENERAL, "Error sending message: %s\n", NET_ErrorString() );
					}
				}
			}
		}
	}
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:55,代码来源:sv_send.c


示例12: Net_NetadrToSockadr

/*
==================
idTCP::Init
==================
*/
bool idTCP::Init( const char *host, short port )
{
    unsigned long	_true = 1;
    struct sockaddr sadr;

    if ( !Sys_StringToNetAdr( host, &address, true ) )
    {
        common->Printf( "Couldn't resolve server name \"%s\"\n", host );
        return false;
    }
    address.type = NA_IP;
    if ( !address.port )
    {
        address.port = port;
    }
    common->Printf( "\"%s\" resolved to %i.%i.%i.%i:%i\n", host,
                    address.ip[0], address.ip[1], address.ip[2], address.ip[3], address.port );
    Net_NetadrToSockadr( &address, &sadr );

    if ( fd )
    {
        common->Warning( "idTCP::Init: already initialized?" );
    }

    if ( ( fd = socket( AF_INET, SOCK_STREAM, 0 ) ) == INVALID_SOCKET )
    {
        fd = 0;
        common->Printf( "ERROR: idTCP::Init: socket: %s\n", NET_ErrorString() );
        return false;
    }

    if ( connect( fd, &sadr, sizeof(sadr)) == SOCKET_ERROR )
    {
        common->Printf( "ERROR: idTCP::Init: connect: %s\n", NET_ErrorString() );
        closesocket( fd );
        fd = 0;
        return false;
    }

    // make it non-blocking
    if( ioctlsocket( fd, FIONBIO, &_true ) == SOCKET_ERROR )
    {
        common->Printf( "ERROR: idTCP::Init: ioctl FIONBIO: %s\n", NET_ErrorString() );
        closesocket( fd );
        fd = 0;
        return false;
    }

    common->DPrintf( "Opened TCP connection\n" );
    return true;
}
开发者ID:revelator,项目名称:Revelator-Doom3,代码行数:56,代码来源:win_net.cpp


示例13: NET_JoinMulticast6

/*
====================
NET_JoinMulticast
Join an ipv6 multicast group
====================
*/
void NET_JoinMulticast6(void)
{
	int err;

	if (ip6_socket == INVALID_SOCKET || multicast6_socket != INVALID_SOCKET || (net_enabled->integer & NET_DISABLEMCAST))
	{
		return;
	}

	if (IN6_IS_ADDR_MULTICAST(&boundto.sin6_addr) || IN6_IS_ADDR_UNSPECIFIED(&boundto.sin6_addr))
	{
		// The way the socket was bound does not prohibit receiving multi-cast packets. So we don't need to open a new one.
		multicast6_socket = ip6_socket;
	}
	else
	{
		if ((multicast6_socket = NET_IP6Socket(net_mcast6addr->string, ntohs(boundto.sin6_port), NULL, &err)) == INVALID_SOCKET)
		{
			// If the OS does not support binding to multicast addresses, like WinXP, at least try with the normal file descriptor.
			multicast6_socket = ip6_socket;
		}
	}

	if (curgroup.ipv6mr_interface)
	{
		if (setsockopt(multicast6_socket, IPPROTO_IPV6, IPV6_MULTICAST_IF,
		               (char *) &curgroup.ipv6mr_interface, sizeof(curgroup.ipv6mr_interface)) < 0)
		{
			Com_Printf("NET_JoinMulticast6: Couldn't set scope on multicast socket: %s\n", NET_ErrorString());

			if (multicast6_socket != ip6_socket)
			{
				closesocket(multicast6_socket);
				multicast6_socket = INVALID_SOCKET;
				return;
			}
		}
	}

	if (setsockopt(multicast6_socket, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *) &curgroup, sizeof(curgroup)))
	{
		Com_Printf("NET_JoinMulticast6: Couldn't join multicast group: %s\n", NET_ErrorString());

		if (multicast6_socket != ip6_socket)
		{
			closesocket(multicast6_socket);
			multicast6_socket = INVALID_SOCKET;
			return;
		}
	}
}
开发者ID:BulldogDrummond,项目名称:etlegacy-mysql,代码行数:57,代码来源:net_ip.c


示例14: NET_IPSocket

/*
====================
NET_Socket
====================
*/
int NET_IPSocket (char *net_interface, int port)
{
	int					newsocket;
	struct sockaddr_in	address;
	u_long				_true = true;
	int					i = 1;
	int					err;

	if ((newsocket = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
	{
		err = WSAGetLastError();
		if (err != WSAEAFNOSUPPORT)
			Com_Printf ("WARNING: UDP_OpenSocket: socket: %s", NET_ErrorString());
		return 0;
	}

	// make it non-blocking
	if (ioctlsocket (newsocket, FIONBIO, &_true) == -1)
	{
		Com_Printf ("WARNING: UDP_OpenSocket: ioctl FIONBIO: %s\n", NET_ErrorString());
		return 0;
	}

	// make it broadcast capable
	if (setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i)) == -1)
	{
		Com_Printf ("WARNING: UDP_OpenSocket: setsockopt SO_BROADCAST: %s\n", NET_ErrorString());
		return 0;
	}

	if (!net_interface || !net_interface[0] || !_stricmp(net_interface, "localhost"))
		address.sin_addr.s_addr = INADDR_ANY;
	else
		NET_StringToSockaddr (net_interface, (struct sockaddr *)&address);

	if (port == PORT_ANY)
		address.sin_port = 0;
	else
		address.sin_port = htons((short)port);

	address.sin_family = AF_INET;

	if( bind (newsocket, (void *)&address, sizeof(address)) == -1)
	{
		Com_Printf ("WARNING: UDP_OpenSocket: bind: %s\n", NET_ErrorString());
		closesocket (newsocket);
		return 0;
	}

	return newsocket;
}
开发者ID:petmac,项目名称:quake2-lite,代码行数:56,代码来源:net_wins.c


示例15: NET_IPXSocket

/*
====================
NET_IPXSocket
====================
*/
int NET_IPXSocket( int port )
{
#ifdef _XBOX
    assert(!"NET_IPXSocket() - Not supported");
    return INVALID_SOCKET;
#else
    SOCKET				newsocket;

    struct sockaddr_ipx	address;
    int					_true = 1;
    int					err;

    if( ( newsocket = socket( AF_IPX, SOCK_DGRAM, NSPROTO_IPX ) ) == INVALID_SOCKET ) {
        err = WSAGetLastError();
        if (err != WSAEAFNOSUPPORT) {
            Com_Printf( "WARNING: IPX_Socket: socket: %s\n", NET_ErrorString() );
        }
        return INVALID_SOCKET;
    }

    // make it non-blocking
    if( ioctlsocket( newsocket, FIONBIO, (unsigned long *)&_true ) == SOCKET_ERROR ) {
        Com_Printf( "WARNING: IPX_Socket: ioctl FIONBIO: %s\n", NET_ErrorString() );
        return INVALID_SOCKET;
    }

    // make it broadcast capable
    if( setsockopt( newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&_true, sizeof( _true ) ) == SOCKET_ERROR ) {
        Com_Printf( "WARNING: IPX_Socket: setsockopt SO_BROADCAST: %s\n", NET_ErrorString() );
        return INVALID_SOCKET;
    }

    address.sa_family = AF_IPX;
    memset( address.sa_netnum, 0, 4 );
    memset( address.sa_nodenum, 0, 6 );
    if( port == PORT_ANY ) {
        address.sa_socket = 0;
    }
    else {
        address.sa_socket = htons( (short)port );
    }

    if( bind( newsocket, (const struct sockaddr *)&address, sizeof(address) ) == SOCKET_ERROR ) {
        Com_Printf( "WARNING: IPX_Socket: bind: %s\n", NET_ErrorString() );
        closesocket( newsocket );
        return INVALID_SOCKET;
    }
    return newsocket;
#endif
}
开发者ID:Drakesinger,项目名称:jediacademypc,代码行数:55,代码来源:win_net.cpp


示例16: NET_IPXSocket

/* <???> ../engine/net_ws.c */
int NET_IPXSocket(int hostshort)
{
	int err;
	u_long optval = 1;
	SOCKET newsocket;
	SOCKADDR_IPX address;

	if((newsocket = CRehldsPlatformHolder::get()->socket(PF_IPX, SOCK_DGRAM, NSPROTO_IPX)) == INVALID_SOCKET)
	{
		err = CRehldsPlatformHolder::get()->WSAGetLastError();

		if (err != WSAEAFNOSUPPORT)
			Con_Printf("WARNING: IPX_Socket: port: %d  socket: %s\n", hostshort, NET_ErrorString(err));
		return 0;
	}
	if (CRehldsPlatformHolder::get()->ioctlsocket(newsocket, FIONBIO, &optval) == SOCKET_ERROR)
	{
		err = CRehldsPlatformHolder::get()->WSAGetLastError();
		Con_Printf("WARNING: IPX_Socket: port: %d  ioctl FIONBIO: %s\n", hostshort, NET_ErrorString(err));
		return 0;
	}
	if (CRehldsPlatformHolder::get()->setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (const char *)&optval, sizeof(optval)) == SOCKET_ERROR)
	{
		err = CRehldsPlatformHolder::get()->WSAGetLastError();
		Con_Printf("WARNING: IPX_Socket: port: %d  setsockopt SO_BROADCAST: %s\n", hostshort, NET_ErrorString(err));
		return 0;
	}
	if (CRehldsPlatformHolder::get()->setsockopt(newsocket, SOL_SOCKET, 4, (const char *)&optval, sizeof(optval)) == SOCKET_ERROR)
	{
		err = CRehldsPlatformHolder::get()->WSAGetLastError();
		return 0;
	}

	address.sa_family = AF_IPX;
	Q_memset(address.sa_netnum, 0, 4);
	Q_memset(address.sa_nodenum, 0, 6);

	if (hostshort == -1)
		address.sa_socket = 0;
	else address.sa_socket = htons((u_short)hostshort);
	
	if (CRehldsPlatformHolder::get()->bind(newsocket, (struct sockaddr *)&address, sizeof(SOCKADDR_IPX)) == SOCKET_ERROR)
	{
		err = CRehldsPlatformHolder::get()->WSAGetLastError();
		Con_Printf("WARNING: IPX_Socket: port: %d  bind: %s\n", hostshort, NET_ErrorString(err));
		CRehldsPlatformHolder::get()->closesocket(newsocket);
		return 0;
	}
	return newsocket;
}
开发者ID:omertelli,项目名称:rehlds,代码行数:51,代码来源:net_ws.cpp


示例17: NET_ErrorString

/*
==================
idTCP::Read
==================
*/
int idTCP::Read( void *data, int size ) {
	int nbytes;

	if ( !fd ) {
		common->Printf("idTCP::Read: not initialized\n");
		return -1;
	}

	if ( ( nbytes = recv( fd, (char *)data, size, 0 ) ) == SOCKET_ERROR ) {
		if ( WSAGetLastError() == WSAEWOULDBLOCK ) {
			return 0;
		}
		common->Printf( "ERROR: idTCP::Read: %s\n", NET_ErrorString() );
		Close();
		return -1;
	}

	// a successful read of 0 bytes indicates remote has closed the connection
	if ( nbytes == 0 ) {
		common->DPrintf( "idTCP::Read: read 0 bytes - assume connection closed\n" );
		return -1;
	}

	return nbytes;
}
开发者ID:AndreiBarsan,项目名称:doom3.gpl,代码行数:30,代码来源:win_net.cpp


示例18: NET_SendPacket

/*
 ==================
 NET_SendPacket
 ==================
*/
void NET_SendPacket (netSrc_t sock, const netAdr_t to, const void *data, int length){

	struct sockaddr	adr;
	int				result, error;

	if (NET_SendLoopPacket(sock, to, data, length))
		return;

	if (to.type != NA_BROADCAST && to.type != NA_IP)
		Com_Error(ERR_FATAL, "NET_SendPacket: bad address type");

	if (net.sockets[sock] == INVALID_SOCKET)
		return;

	NET_NetAdrToSockAdr(&to, &adr);

	result = sendto(net.sockets[sock], (const char *)data, length, 0, &adr, sizeof(adr));

	if (result == SOCKET_ERROR){
		error = WSAGetLastError();

		// WSAEWOULDBLOCK is silent
		if (error == WSAEWOULDBLOCK)
			return;

		// Some PPP links don't allow broadcasts
		if (error == WSAEADDRNOTAVAIL && to.type == NA_BROADCAST)
			return;

		Com_Printf(S_COLOR_RED "NET_SendPacket: %s to %s\n", NET_ErrorString(), NET_AddressToString(to));
	}

	net.packetsSent[sock]++;
	net.bytesSent[sock] += result;
}
开发者ID:Mirrorman95,项目名称:quake-2-evolved,代码行数:40,代码来源:win_network.c


示例19: Sys_SendPacket

/*
==================
Sys_SendPacket
==================
*/
void Sys_SendPacket( int length, const void* data, netadr_t to )
{
	int             ret = SOCKET_ERROR;
	struct sockaddr_storage addr;
	
	if ( to.type != NA_BROADCAST && to.type != NA_IP && to.type != NA_IP6 && to.type != NA_MULTICAST6 )
	{
		Com_Error( ERR_FATAL, "Sys_SendPacket: bad address type" );
		return;
	}
	
	if ( ( ip_socket == INVALID_SOCKET && to.type == NA_IP ) ||
			( ip_socket == INVALID_SOCKET && to.type == NA_BROADCAST ) ||
			( ip6_socket == INVALID_SOCKET && to.type == NA_IP6 ) ||
			( ip6_socket == INVALID_SOCKET && to.type == NA_MULTICAST6 ) )
		return;
		
	if ( to.type == NA_MULTICAST6 && ( net_enabled->integer & NET_DISABLEMCAST ) )
		return;
		
	memset( &addr, 0, sizeof( addr ) );
	NetadrToSockadr( &to, ( struct sockaddr* ) &addr );
	
	if ( usingSocks && to.type == NA_IP )
	{
		socksBuf[0] = 0;    // reserved
		socksBuf[1] = 0;
		socksBuf[2] = 0;    // fragment (not fragmented)
		socksBuf[3] = 1;    // address type: IPV4
		*( int* )&socksBuf[4] = ( ( struct sockaddr_in* )&addr )->sin_addr.s_addr;
		*( short* )&socksBuf[8] = ( ( struct sockaddr_in* )&addr )->sin_port;
		memcpy( &socksBuf[10], data, length );
		ret = sendto( ip_socket, socksBuf, length + 10, 0, &socksRelayAddr, sizeof( socksRelayAddr ) );
	}
	else
	{
		if ( addr.ss_family == AF_INET )
			ret = sendto( ip_socket, ( const char* )data, length, 0, ( struct sockaddr* ) &addr, sizeof( struct sockaddr_in ) );
		else if ( addr.ss_family == AF_INET6 )
			ret = sendto( ip6_socket, ( const char* )data, length, 0, ( struct sockaddr* ) &addr, sizeof( struct sockaddr_in6 ) );
	}
	if ( ret == SOCKET_ERROR )
	{
		int err = socketError;
		
		// wouldblock is silent
		if ( err == EAGAIN )
		{
			return;
		}
		
		// some PPP links do not allow broadcasts and return an error
		if ( ( err == EADDRNOTAVAIL ) && ( ( to.type == NA_BROADCAST ) ) )
		{
			return;
		}
		
		Com_Printf( "Sys_SendPacket: %s\n", NET_ErrorString() );
	}
}
开发者ID:OnlyTheGhosts,项目名称:OWEngine,代码行数:65,代码来源:net_ip.cpp


示例20: NET_GetLocalAddress

static void NET_GetLocalAddress( void )
{
	struct ifaddrs *ifap, *search;

	numIP = 0;

	if ( getifaddrs( &ifap ) )
	{
		Com_Printf( "NET_GetLocalAddress: Unable to get list of network interfaces: %s\n", NET_ErrorString() );
	}
	else
	{
		for ( search = ifap; search; search = search->ifa_next )
		{
			// Only add interfaces that are up.
			if ( ifap->ifa_flags & IFF_UP )
			{
				NET_AddLocalAddress( search->ifa_name, search->ifa_addr, search->ifa_netmask );
			}
		}

		freeifaddrs( ifap );

		Sys_ShowIP();
	}
}
开发者ID:Asvarox,项目名称:Unvanquished,代码行数:26,代码来源:net_ip.c



注:本文中的NET_ErrorString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NET_INC_STATS_BH函数代码示例发布时间:2022-05-30
下一篇:
C++ NET_DBG函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap