예제 #1
0
파일: net_mp.c 프로젝트: Blzut3/Engoo
void MPATH_Listen (qboolean state)
{
	// enable listening
	if (state)
	{
		if (net_acceptsocket != -1)
			return;
		if ((net_acceptsocket = MPATH_OpenSocket (net_hostport)) == -1)
			Sys_Error ("MPATH_Listen: Unable to open accept socket\n");
		return;
	}

	// disable listening
	if (net_acceptsocket == -1)
		return;
	MPATH_CloseSocket (net_acceptsocket);
	net_acceptsocket = -1;
}
예제 #2
0
파일: net_mp.c 프로젝트: luaman/qforge-old
int
MPATH_Init ( void )
{
	int		i;
	struct hostent *local = NULL;
	char	buff[MAXHOSTNAMELEN];
	struct qsockaddr addr;
	char	*p;

	if (COM_CheckParm ("-mpath") == 0)
		return -1;

	flat_selector = __dpmi_allocate_ldt_descriptors(1);
	if (flat_selector == -1) {
		Con_Printf("MPATH_Init: Can't get flat selector\n");
		return -1;
	}
	if (__dpmi_set_segment_base_address(flat_selector, 0) == -1) {
		Con_Printf("MPATH_Init: Can't seg flat base!\n");
		return -1;
	}
	if (__dpmi_set_segment_limit(flat_selector, 0xffffffff) == -1) {
		Con_Printf("MPATH_Init: Can't set segment limit\n");
		return -1;
	}
	// determine my name & address
	if (gethostname(buff, MAXHOSTNAMELEN) == 0)
		local = gethostbyname(buff);
	if (local)
	{
		myAddr = *(int *)local->h_addr_list[0];

		// if the quake hostname isn't set, set it to the machine name
		if (Q_strcmp(hostname -> string, "UNNAMED") == 0)
		{
			// see if it's a text IP address (well, close enough)
			for (p = buff; *p; p++)
				if ((*p < '0' || *p > '9') && *p != '.')
					break;

			// if it is a real name, strip off the domain; we only want the host
			if (*p)
			{
				for (i = 0; i < 15; i++)
					if (buff[i] == '.')
						break;
				buff[i] = 0;
			}
			Cvar_Set (hostname, buff);
		}
	}

	if ((net_controlsocket = MPATH_OpenSocket (0)) == -1)
		Sys_Error("MPATH_Init: Unable to open control socket\n");

	((struct sockaddr_in *)&broadcastaddr)->sin_family = AF_INET;
	((struct sockaddr_in *)&broadcastaddr)->sin_addr.s_addr = INADDR_BROADCAST;
	((struct sockaddr_in *)&broadcastaddr)->sin_port = htons(net_hostport);

	MPATH_GetSocketAddr (net_controlsocket, &addr);
	Q_strcpy(my_tcpip_address, MPATH_AddrToString (&addr));
	p = Q_strrchr (my_tcpip_address, ':');
	if (p)
		*p = 0;

	Con_Printf("MPath Initialized\n");
	tcpipAvailable = true;

	return net_controlsocket;
}