当前位置: 首页>>代码示例>>C++>>正文


C++ NET_AddressToString函数代码示例

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


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

示例1: TV_Upstream_ServerReconnect_f

/*
* TV_Upstream_ServerReconnect_f
* 
* The server is changing levels
*/
static void TV_Upstream_ServerReconnect_f( upstream_t *upstream )
{
	if( upstream->demo.playing )
		return;

	if( upstream->state < CA_CONNECTED )
	{
		Com_Printf( "%s: reconnect request while not connected\n", NET_AddressToString( &upstream->serveraddress ) );
		return;
	}

	if( upstream->demo.recording )
		TV_Upstream_StopDemoRecord( upstream, upstream->demo.autorecording, qfalse );

	Com_Printf( "%s: reconnecting...\n", NET_AddressToString( &upstream->serveraddress ) );

	upstream->connect_count = 0;
	upstream->rejected = 0;
#ifdef TCP_ALLOW_CONNECT
	upstream->connect_time = tvs.realtime;
#else
	upstream->connect_time = tvs.realtime - 1500;
#endif
	upstream->state = CA_HANDSHAKE;
	TV_Upstream_AddReliableCommand( upstream, "new" );
}
开发者ID:codetwister,项目名称:qfusion,代码行数:31,代码来源:tv_upstream_svcmd.c

示例2: SV_ConnectionlessPacket

/*
* SV_ConnectionlessPacket
* 
* A connectionless packet has four leading 0xff
* characters to distinguish it from a game channel.
* Clients that are in the game can still send
* connectionless packets.
*/
void SV_ConnectionlessPacket( const socket_t *socket, const netadr_t *address, msg_t *msg )
{
	connectionless_cmd_t *cmd;
	char *s, *c;

	MSG_BeginReading( msg );
	MSG_ReadLong( msg );    // skip the -1 marker

	s = MSG_ReadStringLine( msg );

	Cmd_TokenizeString( s );

	c = Cmd_Argv( 0 );
	Com_DPrintf( "Packet %s : %s\n", NET_AddressToString( address ), c );

	for( cmd = connectionless_cmds; cmd->name; cmd++ )
	{
		if( !strcmp( c, cmd->name ) )
		{
			cmd->func( socket, address );
			return;
		}
	}

	Com_DPrintf( "Bad connectionless packet from %s:\n%s\n", NET_AddressToString( address ), s );
}
开发者ID:codetwister,项目名称:qfusion,代码行数:34,代码来源:sv_oob.c

示例3: TV_Upstream_Status_f

/*
* TV_Upstream_Status_f
*/
static void TV_Upstream_Status_f( void )
{
	int i;
	qboolean none;
	client_t *client;
	upstream_t *upstream;

	if( !TV_UpstreamForText( Cmd_Argv( 1 ), &upstream ) )
	{
		Com_Printf( "No such connection\n" );
		return;
	}

	if( upstream )
	{
		Com_Printf( "%s" S_COLOR_WHITE ": %s\n", upstream->name, NET_AddressToString( &upstream->serveraddress ) );
		Com_Printf( "Server name: %s\n", upstream->servername );
		Com_Printf( "Connection: %s\n", TV_ConnstateToString( upstream->state ) );
		Com_Printf( "Relay: %s\n", TV_ConnstateToString( upstream->relay.state ) );
	}
	else
	{
		Com_Printf( "lobby\n" );
	}

	Com_Printf( "Downstream connections:\n" );
	none = qtrue;
	for( i = 0; i < tv_maxclients->integer; i++ )
	{
		client = &tvs.clients[i];

		if( client->state == CS_FREE || client->state == CS_ZOMBIE )
			continue;
		if( !client->relay )
		{
			if( upstream )
				continue;
		}
		else
		{
			if( client->relay->upstream != upstream )
				continue;
		}

		Com_Printf( "%3i: %s" S_COLOR_WHITE " (%s)\n", i, client->name, NET_AddressToString( &client->netchan.remoteAddress ) );
		none = qfalse;
	}
	if( none )
		Com_Printf( "- No downstream connections\n" );
}
开发者ID:codetwister,项目名称:qfusion,代码行数:53,代码来源:tv_cmds.c

示例4: CL_MM_Connect

qboolean CL_MM_Connect( const netadr_t *address )
{
	/*
	* ch : this here sends a ticket request to MM.
	* upon response we can set the client state to CA_CONNECTING
	* and actually connect to the gameserver
	*/
	stat_query_t *query;

	// Com_Printf("CL_MM_Connect %s\n", NET_AddressToString( address ) );

	cls.mm_ticket = 0;

	// TODO: if not logged in, force login
	if( !cl_mm_enabled )
		return qfalse;

	// TODO: validate the parameters
	query = sq_api->CreateQuery( "ccc", qfalse );
	if( query == NULL )
		return qfalse;

	// TODO: put the session in a cookie
	sq_api->SetField( query, "csession", va( "%d", cls.mm_session ) );
	// we may have ipv4 or ipv6 in here, and MM currently on supports ipv4..
	sq_api->SetField( query, "saddr", NET_AddressToString( address ) );
	sq_api->SetCallback( query, cl_mm_connect_done, NULL );
	sq_api->Send( query );

	return qtrue;
}
开发者ID:Kaperstone,项目名称:warsow,代码行数:31,代码来源:cl_mm.c

示例5: 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

示例6: MM_MatchList

//================
// MM_MatchesList
// Prints the list of matches to console
//================
void MM_MatchList( void )
{
	int i = 0, count = 0;
	mm_match_t *match;

	for( match = mms.matches ; match ; match = match->next )
	{
		Com_Printf( "Match id: %d\n ping type: %s\n gametype: %s\n skill type: %s\n clients:\n",
		            match->id,
		            match->pingtype == TYPE_ANY ? "any" : "dependent",
		            match->gametype,
		            match->skilltype == TYPE_ANY ? "any" : "dependent" );

		for( i = 0; i < match->maxclients; i++ )
		{
			if( match->clients[i] )
				Com_Printf( "  %s %s (%d): %s\n",
				           match->clients[i]->userid < 1 ? "U" : "R", // registered or not
				           match->clients[i]->nickname,
				           match->clients[i]->userid,
				           NET_AddressToString( &match->clients[i]->connection->address ) );
		}

		count++;
	}

	Com_Printf( "%d match(s)\n", count );
}
开发者ID:Racenet,项目名称:racesow,代码行数:32,代码来源:mm_matches.c

示例7: TV_Downstream_UpstreamlessPacket

/*
* TV_Downstream_UpstreamlessPacket
*/
void TV_Downstream_UpstreamlessPacket( const socket_t *socket, const netadr_t *address, msg_t *msg )
{
	upstreamless_cmd_t *cmd;
	char *s, *c;

	MSG_BeginReading( msg );
	MSG_ReadLong( msg );    // skip the -1 marker

	s = MSG_ReadStringLine( msg );

	if( TV_Downstream_SteamServerQuery( s, socket, address, msg ) )
		return;

	Cmd_TokenizeString( s );
	c = Cmd_Argv( 0 );

	for( cmd = upstreamless_cmds; cmd->name; cmd++ )
	{
		if( !strcmp( c, cmd->name ) )
		{
			cmd->func( socket, address );
			return;
		}
	}

	Com_DPrintf( "Bad downstream connectionless packet from %s:\n%s\n", NET_AddressToString( address ), s );
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:30,代码来源:tv_downstream_oob.c

示例8: TV_Downstream_MasterHeartbeat

/*
* TV_Downstream_MasterHeartbeat
* Send a message to the master every few minutes to
* let it know we are alive, and log information
*/
void TV_Downstream_MasterHeartbeat( void )
{
	int i;
	const socket_t *socket;

	tvs.lobby.last_heartbeat -= tvs.lobby.snapFrameTime;
	if( tvs.lobby.last_heartbeat > 0 )
		return;

	tvs.lobby.last_heartbeat = HEARTBEAT_SECONDS * 1000;

	if( !tv_public->integer )
		return;

	// send to group master
	for( i = 0; i < MAX_MASTERS; i++ )
	{
		if( tv_master_adr[i].type != NA_NOTRANSMIT )
		{
			Com_Printf( "Sending heartbeat to %s\n", NET_AddressToString( &tv_master_adr[i] ) );

			socket = ( tv_master_adr[i].type == NA_IP6 ? &tvs.socket_udp6 : &tvs.socket_udp );

			// warning: "DarkPlaces" is a protocol name here, not a game name. Do not replace it.
			Netchan_OutOfBandPrint( socket, &tv_master_adr[i], "heartbeat %s\n", "DarkPlaces" );
		}
	}
}
开发者ID:Kaperstone,项目名称:warsow,代码行数:33,代码来源:tv_downstream.c

示例9: SV_MasterSendQuit

/*
* SV_MasterSendQuit
* Notifies Steam master servers that the server is shutting down.
*/
void SV_MasterSendQuit( void )
{
	int i;
	const char quitMessage[] = "b\n";

	if( !sv_public->integer || ( sv_maxclients->integer == 1 ) )
		return;

	// never go public when not acting as a game server
	if( sv.state > ss_game )
		return;

	// send to group master
	for( i = 0; i < MAX_MASTERS; i++ )
	{
		sv_master_t *master = &sv_masters[i];

		if( master->steam && ( master->address.type != NA_NOTRANSMIT ) )
		{
			socket_t *socket = ( master->address.type == NA_IP6 ? &svs.socket_udp6 : &svs.socket_udp );

			if( dedicated && dedicated->integer )
				Com_Printf( "Sending quit to %s\n", NET_AddressToString( &master->address ) );

			NET_SendPacket( socket, ( const uint8_t * )quitMessage, sizeof( quitMessage ), &master->address );
		}
	}
}
开发者ID:futurepneu,项目名称:racemod,代码行数:32,代码来源:sv_oob.c

示例10: CL_ParseStatusMessage

/*
* CL_ParseStatusMessage
* Handle a reply from a ping
*/
void CL_ParseStatusMessage( const socket_t *socket, const netadr_t *address, msg_t *msg )
{
	char *s = MSG_ReadString( msg );
	serverlist_t *pingserver;
	char adrString[64];

	Com_DPrintf( "%s\n", s );

	Q_strncpyz( adrString, NET_AddressToString( address ), sizeof( adrString ) );

	// ping response
	pingserver = CL_ServerFindInList( masterList, adrString );
	if( !pingserver )
		pingserver = CL_ServerFindInList( favoritesList, adrString );

	if( pingserver && pingserver->pingTimeStamp ) // valid ping
	{
		unsigned int ping = Sys_Milliseconds() - pingserver->pingTimeStamp;
		CL_UIModule_AddToServerList( adrString, va( "\\\\ping\\\\%i%s", ping, s ) );
		pingserver->pingTimeStamp = 0;
		pingserver->lastValidPing = Com_DaysSince1900();
		return;
	}

	// assume LAN response
	if( NET_IsLANAddress( address ) && ( localQueryTimeStamp + LAN_SERVER_PINGING_TIMEOUT > Sys_Milliseconds() ) ) {
		unsigned int ping = Sys_Milliseconds() - localQueryTimeStamp;
		CL_UIModule_AddToServerList( adrString, va( "\\\\ping\\\\%i%s", ping, s ) );
		return;
	}

	// add the server info, but ignore the ping, cause it's not valid
	CL_UIModule_AddToServerList( adrString, s );
}
开发者ID:codetwister,项目名称:qfusion,代码行数:38,代码来源:cl_serverlist.c

示例11: 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

示例12: TV_Downstream_AddMaster_f

/*
* TV_Downstream_AddMaster_f
* Add a master server to the list
*/
static void TV_Downstream_AddMaster_f( const char *master )
{
	int i;

	if( !master || !master[0] )
		return;

	if( !tv_public->integer )
	{
		Com_Printf( "'TV_Downstream_AddMaster_f' Only public servers use masters.\n" );
		return;
	}

	for( i = 0; i < MAX_MASTERS; i++ )
	{
		if( tv_master_adr[i].type != NA_NOTRANSMIT )
			continue;

		if( !NET_StringToAddress( master, &tv_master_adr[i] ) )
		{
			Com_Printf( "'SV_AddMaster_f' Bad Master server address: %s\n", master );
			return;
		}
		if( NET_GetAddressPort( &tv_master_adr[i] ) == 0 )
			NET_SetAddressPort( &tv_master_adr[i], PORT_MASTER );

		Com_Printf( "Added new master server #%i at %s\n", i, NET_AddressToString( &tv_master_adr[i] ) );
		return;
	}

	Com_Printf( "'TV_Downstream_AddMaster_f' List of master servers is already full\n" );
}
开发者ID:Kaperstone,项目名称:warsow,代码行数:36,代码来源:tv_downstream.c

示例13: SVC_GetChallenge

/*
* SVC_GetChallenge
* 
* Returns a challenge number that can be used
* in a subsequent client_connect command.
* We do this to prevent denial of service attacks that
* flood the server with invalid connection IPs.  With a
* challenge, they must give a valid IP address.
*/
static void SVC_GetChallenge( const socket_t *socket, const netadr_t *address )
{
	int i;
	int oldest;
	int oldestTime;

	oldest = 0;
	oldestTime = 0x7fffffff;

	if( sv_showChallenge->integer )
		Com_Printf( "Challenge Packet %s\n", NET_AddressToString( address ) );

	// see if we already have a challenge for this ip
	for( i = 0; i < MAX_CHALLENGES; i++ )
	{
		if( NET_CompareBaseAddress( address, &svs.challenges[i].adr ) )
			break;
		if( svs.challenges[i].time < oldestTime )
		{
			oldestTime = svs.challenges[i].time;
			oldest = i;
		}
	}

	if( i == MAX_CHALLENGES )
	{
		// overwrite the oldest
		svs.challenges[oldest].challenge = rand() & 0x7fff;
		svs.challenges[oldest].adr = *address;
		svs.challenges[oldest].time = Sys_Milliseconds();
		i = oldest;
	}

	Netchan_OutOfBandPrint( socket, address, "challenge %i", svs.challenges[i].challenge );
}
开发者ID:codetwister,项目名称:qfusion,代码行数:44,代码来源:sv_oob.c

示例14: SV_MasterHeartbeat

/*
* SV_MasterHeartbeat
* Send a message to the master every few minutes to
* let it know we are alive, and log information
*/
void SV_MasterHeartbeat( void )
{
	int i;

	svc.lastHeartbeat -= svc.snapFrameTime;
	if( svc.lastHeartbeat > 0 )
		return;

	svc.lastHeartbeat = HEARTBEAT_SECONDS * 1000;

	if( !sv_public->integer )
		return;

	// never go public when not acting as a game server
	if( sv.state > ss_game )
		return;

	// send to group master
	for( i = 0; i < MAX_MASTERS; i++ )
	{
		if( master_adr[i].type != NA_NOTRANSMIT )
		{
			socket_t *socket;

			if( dedicated && dedicated->integer )
				Com_Printf( "Sending heartbeat to %s\n", NET_AddressToString( &master_adr[i] ) );

			socket = ( master_adr[i].type == NA_IP6 ? &svs.socket_udp6 : &svs.socket_udp );

			// warning: "DarkPlaces" is a protocol name here, not a game name. Do not replace it.
			Netchan_OutOfBandPrint( socket, &master_adr[i], "heartbeat DarkPlaces\n" );
		}
	}
}
开发者ID:codetwister,项目名称:qfusion,代码行数:39,代码来源:sv_oob.c

示例15: CL_Mumble_Update

/*
* CL_Mumble_Update
*/
void CL_Mumble_Update( const vec3_t origin, const vec3_t forward, const vec3_t right, const vec3_t up, const char *identity )
{
	vec3_t mp, mf, mt;
	char context[256];

	if( !cl_mumble->integer )
		return;
	if( !identity )
		return;

	VectorScale( origin, cl_mumble_scale->value, mp );
	VectorSet( mf, forward[0], forward[2], forward[1] );
	VectorSet( mt, up[0], up[2], up[1] );

	if( cl_mumble->integer == 2 )
		Com_Printf( "MumbleUpdate:\n%f, %f, %f\n%f, %f, %f\n%f, %f, %f", mp[0], mp[1], mp[2], mf[0], mf[1], mf[2], mt[0], mt[1], mt[2] );

	mumble_update_coordinates( mp, mf, mt );

	// for Mumble 1.2+  http://mumble.sourceforge.net/Link
	mumble_set_identity( identity );

	// TODO: add team to context?
	Q_strncpyz( context, NET_AddressToString( &cls.serveraddress ), sizeof( context ) );
	mumble_set_context( ( const unsigned char * )context, strlen( context ) + 1 );
}
开发者ID:Kaperstone,项目名称:warsow,代码行数:29,代码来源:cl_sound.c


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