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

C++ NetadrToSockadr函数代码示例

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

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



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

示例1: NET_SendPacket

void
NET_SendPacket (int length, const void *data, netadr_t to)
{
	int         ret;
	AF_address_t addr;

	NetadrToSockadr (&to, &addr);

	ret = sendto (net_socket, data, length, 0, &addr.sa, SA_LEN (&addr.sa));
	if (ret == -1) {
#ifdef _WIN32
		int         err = WSAGetLastError ();

		if (err == WSAEADDRNOTAVAIL)
			Sys_Printf ("NET_SendPacket Warning: %i\n", err);
#else /* _WIN32 */
		int         err = errno;

		if (err == ECONNREFUSED)
			return;
#endif /* _WIN32 */
		if (err == EWOULDBLOCK)
			return;

		Sys_Printf ("NET_SendPacket: %s\n", strerror (err));
	}
}
开发者ID:EIREXE,项目名称:Quakeforge-gcw0,代码行数:27,代码来源:net_udp.c


示例2: NET_SendPacket

//=============================================================================
void NET_SendPacket (int length, void *data, netadr_t to)
{
	int ret;
	int outlen;
	struct sockaddr_in	addr;
	char string[120];

	NetadrToSockadr (&to, &addr);
	HuffEncode((unsigned char *)data,huffbuff,length,&outlen);

#ifdef _DEBUG
	sprintf(string,"in: %d  out: %d  ratio: %f\n",HuffIn, HuffOut, 1-(float)HuffOut/(float)HuffIn);
	OutputDebugString(string);

	CalcFreq((unsigned char *)data, length);
#endif

	ret = sendto (net_socket, (char *) huffbuff, outlen, 0, (struct sockaddr *)&addr, sizeof(addr) );
	if (ret == -1)
	{
		int errno = WSAGetLastError();

		Con_Printf ("NET_SendPacket ERROR: %i", errno);
	}
}
开发者ID:bsmr-games,项目名称:Hexen2,代码行数:26,代码来源:net_wins.c


示例3: NET_SendPacket

void NET_SendPacket(int length, byte *data, netadr_t to)
{
    int ret;
    struct sockaddr_in addr;

    NetadrToSockadr(&to, &addr);

    ret = sendto(net_socket, (const char*)data, length, 0, (struct sockaddr *)&addr, sizeof(addr) );

    if (ret == -1)
    {
#ifdef _WIN32
		  int err = WSAGetLastError();

		  if (err == WSAEWOULDBLOCK)
			  return;
#else
          if (errno == EWOULDBLOCK)
              return;
          if (errno == ECONNREFUSED)
              return;
          printf("NET_SendPacket: %s\n", strerror(errno));
#endif
    }
}
开发者ID:JohnnyonFlame,项目名称:odamex,代码行数:25,代码来源:i_net.cpp


示例4: Com_sprintf

const char *NET_AdrToString(netadr_t a)
{
	static char s[NET_ADDRSTRMAXLEN];

	if (a.type == NA_LOOPBACK)
	{
		Com_sprintf(s, sizeof(s), "loopback");
	}
	else if (a.type == NA_BOT)
	{
		Com_sprintf(s, sizeof(s), "bot");
	}
	else if (a.type == NA_IP)
	{
		// Port has to be returned along with ip address because of compatibility
		Com_sprintf(s, sizeof(s), "%i.%i.%i.%i:%hu",
		            a.ip[0], a.ip[1], a.ip[2], a.ip[3], BigShort(a.port));
	}
#ifdef FEATURE_IPV6
	else if (a.type == NA_IP6)
	{
		// FIXME: add port for compatibility
		// (joining a server through the server browser)
		struct sockaddr_storage sadr;

		memset(&sadr, 0, sizeof(sadr));
		NetadrToSockadr(&a, (struct sockaddr *) &sadr);
		Sys_SockaddrToString(s, sizeof(s), (struct sockaddr *) &sadr);
	}
#endif

	return s;
}
开发者ID:BulldogDrummond,项目名称:etlegacy-mysql,代码行数:33,代码来源:net_ip.c


示例5: NET_SendPacket

void NET_SendPacket (netsrc_t sock, int length, void *data, netadr_t to) {
	int ret;
	struct sockaddr_in	addr;
	int net_socket;

	if (to.type == NA_LOOPBACK) {
		NET_SendLoopPacket (sock, length, data, to);
		return;
	}

	net_socket = ip_sockets[sock];
	if (net_socket == -1)
		return;

	NetadrToSockadr (&to, &addr);

	ret = sendto (net_socket, data, length, 0, (struct sockaddr *)&addr, sizeof(addr) );
	if (ret == -1) {
		if (errno == EWOULDBLOCK)
			return;
		if (errno == ECONNREFUSED)
			return;
		Sys_Printf ("NET_SendPacket: %s\n", strerror(errno));
	}
}
开发者ID:d2-d2,项目名称:qw_demo_downloader,代码行数:25,代码来源:net_udp.c


示例6: NET_IsClientLegal

// Returns true if we can't bind the address locally--in other words, 
// the IP is NOT one of our interfaces.
qboolean NET_IsClientLegal(netadr_t *adr)
{
	struct sockaddr_in sadr;
	int newsocket;

#if 0
	if (adr->ip[0] == 127)
		return false; // no local connections period

	NetadrToSockadr (adr, &sadr);

	if ((newsocket = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
		Sys_Error ("NET_IsClientLegal: socket:", strerror(errno));

	sadr.sin_port = 0;

	if( bind (newsocket, (void *)&sadr, sizeof(sadr)) == -1) 
	{
		// It is not a local address
		close(newsocket);
		return true;
	}
	close(newsocket);
	return false;
#else
	return true;
#endif
}
开发者ID:ACIIL,项目名称:Quake,代码行数:30,代码来源:net_udp.c


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


示例8: SB_PingTree_SendQueryThread

DWORD WINAPI SB_PingTree_SendQueryThread(void *thread_arg)
{
	proxy_request_queue *queue = (proxy_request_queue *) thread_arg;
	int i, ret;
	double interval_ms = (1.0 / sb_proxinfopersec.value) * 1000.0;
	timerresolution_session_t timersession = {0, 0};

	Sys_TimerResolution_InitSession(&timersession);
	Sys_TimerResolution_RequestMinimum(&timersession);

	for (i = 0; i < queue->items; i++) {
		if (!queue->data[i].done) {
			struct sockaddr_storage addr_to;
			netadr_t netadr = SB_NodeNetadr_Get(queue->data[i].nodeid);

			NetadrToSockadr(&netadr, &addr_to);
			ret = sendto(queue->data[i].sock,
				PROXY_PINGLIST_QUERY, PROXY_PINGLIST_QUERY_LEN, 0,
				(struct sockaddr *) &addr_to, sizeof (struct sockaddr));
			if (ret < 0) {
				Com_DPrintf("SB_PingTree_SendQueryThread sendto returned %d\n", ret);
			}
			Sys_MSleep(interval_ms);
		}

		if (queue->allrecved) break;
	}

	Sys_TimerResolution_Clear(&timersession);

	queue->sending_done = true;

	return 0;
}
开发者ID:jite,项目名称:jquake,代码行数:34,代码来源:EX_browser_pathfind.c


示例9: NET_SendPacket

void NET_SendPacket (buf_t &buf, netadr_t &to)
{
    int                   ret;
    struct sockaddr_in    addr;

    NetadrToSockadr (&to, &addr);

	ret = sendto (net_socket, (const char *)buf.ptr(), buf.size(), 0, (struct sockaddr *)&addr, sizeof(addr));

	buf.clear();

    if (ret == -1)
    {
#ifdef _WIN32
          int err = WSAGetLastError();

          // wouldblock is silent
          if (err == WSAEWOULDBLOCK)
              return;
#else
          if (errno == EWOULDBLOCK)
              return;
          if (errno == ECONNREFUSED)
              return;
          Printf (PRINT_HIGH, "NET_SendPacket: %s\n", strerror(errno));
#endif
    }
}
开发者ID:JohnnyonFlame,项目名称:odamex,代码行数:28,代码来源:i_net.cpp


示例10: AddressToString

std::string AddressToString( const netadr_t& address, bool with_port )
{

    if ( address.type == netadrtype_t::NA_LOOPBACK )
    {
        return "loopback";
    }
    else if ( address.type == netadrtype_t::NA_BOT )
    {
        return "bot";
    }
    else if ( address.type == netadrtype_t::NA_IP ||
              address.type == netadrtype_t::NA_IP6 ||
              address.type == netadrtype_t::NA_IP_DUAL )
    {
        char s[ NET_ADDR_STR_MAX_LEN ];
        sockaddr_storage sadr = {0};
        NetadrToSockadr( &address, reinterpret_cast<sockaddr*>(&sadr) );
        Sys_SockaddrToString( s, sizeof(s), reinterpret_cast<sockaddr*>(&sadr) );

        std::string result = s;
        if ( with_port )
        {
            if ( NET_IS_IPv6( address.type ) )
            {
                result = '[' + result + ']';
            }
                result += ':' + std::to_string(ntohs(GetPort(address)));
        }
        return result;
    }

    return "";
}
开发者ID:ChunHungLiu,项目名称:Unvanquished,代码行数:34,代码来源:Network.cpp


示例11: Sys_SendPacket

/*
==================
Sys_SendPacket
==================
*/
void Sys_SendPacket( int length, const void *data, netadr_t to ) {
	int				ret;
	struct sockaddr	addr;
	SOCKET			net_socket;

	if( to.type == NA_BROADCAST ) {
		net_socket = ip_socket;
	}
	else if( to.type == NA_IP ) {
		net_socket = ip_socket;
	}
	else if( to.type == NA_IPX ) {
		net_socket = ipx_socket;
	}
	else if( to.type == NA_BROADCAST_IPX ) {
		net_socket = ipx_socket;
	}
	else {
		Com_Error( ERR_FATAL, "Sys_SendPacket: bad address type" );
		return;
	}

	if( !net_socket ) {
		return;
	}

	NetadrToSockadr( &to, &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( net_socket, socksBuf, length+10, 0, &socksRelayAddr, sizeof(socksRelayAddr) );
	}
	else {
		ret = sendto( net_socket, (const char *)data, length, 0, &addr, sizeof(addr) );
	}
	if( ret == SOCKET_ERROR ) {
		int err = WSAGetLastError();

		// wouldblock is silent
		if( err == WSAEWOULDBLOCK ) {
			return;
		}

		// some PPP links do not allow broadcasts and return an error
		if( ( err == WSAEADDRNOTAVAIL ) && ( ( to.type == NA_BROADCAST ) || ( to.type == NA_BROADCAST_IPX ) ) ) {
			return;
		}

		Com_Printf( "NET_SendPacket: %s\n", NET_ErrorString() );
	}
}
开发者ID:blaenk,项目名称:jedioutcast,代码行数:62,代码来源:win_net.cpp


示例12: NetadrToSockadr

/*
==================
idTCP::Init
==================
*/
bool idTCP::Init( const char *host, short port )
{
    struct sockaddr_in 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 );
    NetadrToSockadr(&address, &sadr);

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

    if ((fd = socket(PF_INET, SOCK_STREAM, 0)) == -1)
    {
        fd = 0;
        common->Printf("ERROR: idTCP::Init: socket: %s\n", strerror(errno));
        return false;
    }

    if ( connect( fd, (const sockaddr *)&sadr, sizeof( sadr ) ) == -1 )
    {
        common->Printf( "ERROR: idTCP::Init: connect: %s\n", strerror( errno ) );
        close( fd );
        fd = 0;
        return false;
    }

    int status;
    if ((status = fcntl(fd, F_GETFL, 0)) != -1)
    {
        status |= O_NONBLOCK; /* POSIX */
        status = fcntl(fd, F_SETFL, status);
    }
    if (status == -1)
    {
        common->Printf("ERROR: idTCP::Init: fcntl / O_NONBLOCK: %s\n", strerror(errno));
        close(fd);
        fd = 0;
        return false;
    }

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


示例13: NET_SendPacket

void NET_SendPacket (netsrc_t sock, int length, void *data, netadr_t to)
{
	int		ret;
	struct sockaddr_in	addr;
	int		net_socket;

	if ( to.type == NA_LOOPBACK )
	{
		NET_SendLoopPacket (sock, length, data, to);
		return;
	}

	if (to.type == NA_BROADCAST)
	{
		net_socket = ip_sockets[sock];
		if (!net_socket)
			return;
	}
	else if (to.type == NA_IP)
	{
		net_socket = ip_sockets[sock];
		if (!net_socket)
			return;
	}
	else if (to.type == NA_IPX)
	{
		net_socket = ipx_sockets[sock];
		if (!net_socket)
			return;
	}
	else if (to.type == NA_BROADCAST_IPX)
	{
		net_socket = ipx_sockets[sock];
		if (!net_socket)
			return;
	}
	else
		Com_Error (ERR_FATAL, "NET_SendPacket: bad address type");

	NetadrToSockadr (&to, &addr);

// >>> FIX: For Nintendo Wii using devkitPPC / libogc
// Switching to the equivalent function in the platform:
	//ret = sendto (net_socket, data, length, 0, (struct sockaddr *)&addr, sizeof(addr) );
	//if (ret == -1)
	ret = net_sendto (net_socket, data, length, 0, (struct sockaddr *)&addr, 8);
	if (ret < 0)
// <<< FIX
	{
		Com_Printf ("NET_SendPacket ERROR: %s to %s\n", NET_ErrorString(),
				NET_AdrToString (to));
	}
}
开发者ID:Izhido,项目名称:qrevpak,代码行数:53,代码来源:net_udp.c


示例14: UDP_Write

int
UDP_Write(int socket, const void *buf, int len, const netadr_t *addr)
{
    struct sockaddr_in saddr;
    int ret;

    NetadrToSockadr(addr, &saddr);
    ret = sendto(socket, buf, len, 0, (struct sockaddr *)&saddr, sizeof(saddr));
    if (ret == -1 && errno == EWOULDBLOCK)
	return 0;
    return ret;
}
开发者ID:CatalystG,项目名称:tyrquake,代码行数:12,代码来源:net_udp.c


示例15: Sys_SendVoicePacket

/*
==================
Sys_SendVoicePacket
==================
*/
void Sys_SendVoicePacket( int length, const void *data, netadr_t to ) {
    int				ret;
    struct sockaddr	addr;

    // check for valid packet intentions (direct send or broadcast)
    //
    if( to.type != NA_IP && to.type != NA_BROADCAST )
    {
        Com_Error( ERR_FATAL, "Sys_SendVoicePacket: bad address type" );
        return;
    }

    // check we have our voice socket set up
    //
    if( v_socket == INVALID_SOCKET) {
        return;
    }

    NetadrToSockadr( &to, &addr );
#ifdef SOF2_METRICS
    gXBL_NumberVoicePacketsSent++;
    gXBL_SizeVoicePacketsSent += length;
#endif
    /*if( usingSocks && to.type == NA_IP ) {
    	vsocksBuf[0] = 0;	// reserved
    	vsocksBuf[1] = 0;
    	vsocksBuf[2] = 0;	// fragment (not fragmented)
    	vsocksBuf[3] = 1;	// address type: IPV4
    	*(int *)&vsocksBuf[4] = ((struct sockaddr_in *)&addr)->sin_addr.s_addr;
    	*(short *)&vsocksBuf[8] = ((struct sockaddr_in *)&addr)->sin_port;
    	memcpy( &vsocksBuf[10], data, length );
    	ret = sendto( v_socket, vsocksBuf, length+10, 0, &socksRelayAddr, sizeof(socksRelayAddr) );
    }
    else {*/
    ret = sendto( v_socket, (const char *)data, length, 0, &addr, sizeof(addr) );
    //}

    if( ret == SOCKET_ERROR ) {
        int err = WSAGetLastError();

        // wouldblock is silent
        if( err == WSAEWOULDBLOCK ) {
            return;
        }

        // some PPP links do not allow broadcasts and return an error
        if( ( err == WSAEADDRNOTAVAIL ) && ( ( to.type == NA_BROADCAST ) || ( to.type == NA_BROADCAST_IPX ) ) ) {
            return;
        }

        Com_DPrintf( "NET_SendVoicePacket: %s\n", NET_ErrorString() );
    }
}
开发者ID:Drakesinger,项目名称:jediacademypc,代码行数:58,代码来源:win_net.cpp


示例16: NET_SendPacket

void NET_SendPacket (netsrc_t sock, int length, void *data, netadr_t to)
{
	int		ret;
	struct sockaddr_in	addr;
	int		net_socket;

	if ( to.type == NA_LOOPBACK )
	{
		NET_SendLoopPacket (sock, length, data, to);
		return;
	}

	if (to.type == NA_BROADCAST)
	{
		net_socket = ip_sockets[sock];
		if (!net_socket)
			return;
	}
	else if (to.type == NA_IP)
	{
		net_socket = ip_sockets[sock];
		if (!net_socket)
			return;
	}
	else if (to.type == NA_IPX)
	{
		net_socket = ipx_sockets[sock];
		if (!net_socket)
			return;
	}
	else if (to.type == NA_BROADCAST_IPX)
	{
		net_socket = ipx_sockets[sock];
		if (!net_socket)
			return;
	}
	else 
	{
		Com_Error (ERR_FATAL, "NET_SendPacket: bad address type");
		return;
	}	

	NetadrToSockadr (&to, &addr);

	ret = sendto (net_socket, data, length, 0, (struct sockaddr *)&addr, sizeof(addr) );
	if (ret == -1)
	{
		Com_Printf ("NET_SendPacket ERROR: %s to %s\n", NET_ErrorString(),
				NET_AdrToString (to));
	}
}
开发者ID:jitspoe,项目名称:starviewer,代码行数:51,代码来源:net_udp.c


示例17: NET_SendPacket

void NET_SendPacket (int length, void *data, netadr_t to)
{
	int ret;
	struct sockaddr_in	addr;

	NetadrToSockadr (&to, &addr);

	ret = sendto (net_socket, data, length, 0, (struct sockaddr *)&addr, sizeof(addr) );
	if (ret == -1) {
		if (errno == EWOULDBLOCK)
			return;
		if (errno == ECONNREFUSED)
			return;
		Sys_Printf ("NET_SendPacket: %s\n", strerror(errno));
	}
}
开发者ID:ACIIL,项目名称:Quake,代码行数:16,代码来源:net_udp.c


示例18: Com_sprintf

const char	*NET_AdrToString (netadr_t a)
{
	static	char	s[NET_ADDRSTRMAXLEN];

	if (a.type == NA_LOOPBACK)
		Com_sprintf (s, sizeof(s), "loopback");
	else if (a.type == NA_IP || a.type == NA_IP6)
	{
		struct sockaddr_storage sadr;
	
		memset(&sadr, 0, sizeof(sadr));
		NetadrToSockadr(&a, (struct sockaddr *) &sadr);
		Sys_SockaddrToString(s, sizeof(s), (struct sockaddr *) &sadr);
	}

	return s;
}
开发者ID:darklegion,项目名称:tremulous,代码行数:17,代码来源:net_ip.c


示例19: NET_SendPacket

int NET_SendPacket (netsrc_t sock, int length, const void *data, netadr_t *to)
{
	int		net_socket;

	if (to->type == NA_IP)
	{
		net_socket = ip_sockets[sock];
		if (!net_socket)
			return 0;
	}
#ifndef DEDICATED_ONLY
	else if ( to->type == NA_LOOPBACK )
	{
		NET_SendLoopPacket (sock, length, data);
		return 1;
	}
#endif
	else if (to->type == NA_BROADCAST)
	{
		net_socket = ip_sockets[sock];
		if (!net_socket)
			return 0;
	}
	else
	{
		Com_Error (ERR_FATAL, "NET_SendPacket: bad address type");
		return 0;
	}

	struct sockaddr_in	addr;
	NetadrToSockadr (to, &addr);

	assert(length > 0);
	assert(length < 0x10000);

	uint16_t size = length;
	fuzzWrite(reinterpret_cast<const char *>(&size), sizeof(size));
	fuzzWrite(reinterpret_cast<const char *>(to),    sizeof(*to));
	fuzzWrite(reinterpret_cast<const char *>(data),  size);

	return 0;
}
开发者ID:turol,项目名称:webquake2,代码行数:42,代码来源:net_afl.cpp


示例20: GetServerInfo

void GetServerInfo(server_data *serv)
{
    socket_t newsocket;
    struct sockaddr_storage server;
    int ret;
    char answer[5000];
    fd_set fd;
    struct timeval tv;

    // so we have a socket
    newsocket = UDP_OpenSocket(PORT_ANY);
    NetadrToSockadr (&(serv->address), &server);

    // send status request
    ret = sendto (newsocket, senddata, sizeof(senddata), 0,
                  (struct sockaddr *)&server, sizeof(server) );

    if (ret == -1)
        return;

    //fd.fd_count = 1;
    //fd.fd_array[0] = newsocket;
    FD_ZERO(&fd);
    FD_SET(newsocket, &fd);
    tv.tv_sec = 0;
    tv.tv_usec = 1000 * 1.5 * sb_infotimeout.value; // multiply timeout by 1.5
    ret = select(newsocket+1, &fd, NULL, NULL, &tv);

    // get answer
    if (ret > 0)
        ret = recvfrom (newsocket, answer, 5000, 0, NULL, NULL);

    if (ret > 0  &&  ret < 5000)
    {
        answer[ret] = 0;
        server_during_update = 1;
        Reset_Server(serv);
        Parse_Serverinfo(serv, answer);
        server_during_update = 0;
    }
    closesocket(newsocket);
}
开发者ID:Classic-Fortress,项目名称:client,代码行数:42,代码来源:EX_browser_net.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ Netchan_OutOfBandPrint函数代码示例发布时间:2022-05-30
下一篇:
C++ NetSetTimeout函数代码示例发布时间: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