qstat.c
/*
 * Functions for binding sockets to Quake servers
 */
Functions for binding sockets to Quake servers
Functions for binding sockets to Quake servers
int bind_qserver_post(struct qserver *server)
{
	server->state = STATE_CONNECTED;
	if (server->type->flags &TF_TCP_CONNECT)
	{
		int one = 1;
		if ( -1 == setsockopt(server->fd, IPPROTO_TCP, TCP_NODELAY, (char*) &one, sizeof(one)) )
		{
			perror( "Failed to set TCP no delay" );
		}
	}
	if ( server->type->id & MASTER_SERVER )
	{
		int sockbuf = RECV_BUF;
		if ( -1 == setsockopt(server->fd, SOL_SOCKET, SO_RCVBUF, (void*)&sockbuf, sizeof(sockbuf)) )
		{
			perror( "Failed to set socket buffer" );
		}
	}
#ifndef _WIN32
	if (server->fd >= max_connmap)
	{
		int old_max = max_connmap;
		max_connmap = server->fd + 32;
		connmap = (struct qserver **)realloc(connmap, max_connmap *sizeof(struct qserver*));
		memset(&connmap[old_max], 0, (max_connmap - old_max) *sizeof(struct qserver*));
	}
	connmap[server->fd] = server;
#endif
#ifdef _WIN32
	{
		int i;
		for (i = 0; i < max_connmap; i++)
		{
			if (connmap[i] == NULL)
			{
				connmap[i] = server;
				break;
			}
		}
		if (i >= max_connmap)
		{
			printf("could not put server in connmap\n");
		}
	}
#endif
	return 0;
}
int bind_qserver_post ( struct qserver * server ) { server -> state = STATE_CONNECTED ; if ( server -> type -> flags & TF_TCP_CONNECT ) { int one = 1 ; if ( -1 == setsockopt ( server -> fd , IPPROTO_TCP , TCP_NODELAY , ( char * ) & one , sizeof ( one ) ) ) { perror ( " " ) ; } } if ( server -> type -> id & MASTER_SERVER ) { int sockbuf = RECV_BUF ; if ( -1 == setsockopt ( server -> fd , SOL_SOCKET , SO_RCVBUF , ( void * ) & sockbuf , sizeof ( sockbuf ) ) ) { perror ( " " ) ; } } #ifndef _WIN32 if ( server -> fd >= max_connmap ) { int old_max = max_connmap ; max_connmap = server -> fd + 32 ; connmap = ( struct qserver * * ) realloc ( connmap , max_connmap * sizeof ( struct qserver * ) ) ; memset ( & connmap [ old_max ] , 0 , ( max_connmap - old_max ) * sizeof ( struct qserver * ) ) ; } connmap [ server -> fd ] = server ; #endif #ifdef _WIN32 { int i ; for ( i = 0 ; i < max_connmap ; i ++ ) { if ( connmap [ i ] == NULL ) { connmap [ i ] = server ; break ; } } if ( i >= max_connmap ) { printf ( " \n " ) ; } } #endif return 0 ; }
Functions for binding sockets to Quake servers
Functions for binding sockets to Quake servers
// Use a large buffer so we dont miss packets