Exemplo n.º 1
0
void
NET_OpenIP(void)
{
	cvar_t *port, *ip;

	port = Cvar_Get("port", va("%i", PORT_SERVER), CVAR_NOSET);
	ip = Cvar_Get("ip", "localhost", CVAR_NOSET);

	if (!ip6_sockets[NS_SERVER])
	{
		ip6_sockets[NS_SERVER] = NET_Socket(ip->string, port->value,
				NS_SERVER, AF_INET6);
	}

	if (!ip6_sockets[NS_CLIENT])
	{
		ip6_sockets[NS_CLIENT] = NET_Socket(ip->string, PORT_ANY,
				NS_CLIENT, AF_INET6);
	}

	if (!ip_sockets[NS_SERVER])
	{
		ip_sockets[NS_SERVER] = NET_Socket(ip->string, port->value,
				NS_SERVER, AF_INET);
	}

	if (!ip_sockets[NS_CLIENT])
	{
		ip_sockets[NS_CLIENT] = NET_Socket(ip->string, PORT_ANY,
				NS_CLIENT, AF_INET);
	}
}
Exemplo n.º 2
0
/*
====================
NET_OpenIP
====================
*/
void NET_OpenIP (void)
{
	cvar_t	*port, *ip;

	port = Cvar_Get ("port", va("%i", PORT_SERVER), CVAR_NOSET);
	ip = Cvar_Get ("ip", "localhost", CVAR_NOSET);

	if (!ip_sockets[NS_SERVER]) {
		server_port = port;	// added for r1ch fix
		ip_sockets[NS_SERVER] = NET_Socket (ip->string, port->value);
	}
	if (!ip_sockets[NS_CLIENT])
		ip_sockets[NS_CLIENT] = NET_Socket (ip->string, PORT_ANY);
}
Exemplo n.º 3
0
static boolean NET_OpenSocket(void)
{
	memset(clientaddress, 0, sizeof (clientaddress));

	//CONS_Printf("SDL_Net Code starting up\n");

	I_NetSend = NET_Send;
	I_NetGet = NET_Get;
	I_NetCloseSocket = NET_CloseSocket;
	I_NetFreeNodenum = NET_FreeNodenum;
	I_NetMakeNode = NET_NetMakeNode;

	//I_NetCanSend = NET_CanSend;

	// build the socket but close it first
	NET_CloseSocket();
	mysocket = NET_Socket();

	if (!mysocket)
		return false;

	// for select
	myset = SDLNet_AllocSocketSet(1);
	if (!myset)
	{
		CONS_Printf("SDL_Net: %s",SDLNet_GetError());
		return false;
	}
	if (SDLNet_UDP_AddSocket(myset,mysocket) == -1)
	{
		CONS_Printf("SDL_Net: %s",SDLNet_GetError());
		return false;
	}
	return true;
}
/*
 * Class:     java_net_DualStackPlainSocketImpl
 * Method:    socket0
 * Signature: (ZZ)I
 */
JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_socket0
  (JNIEnv *env, jclass clazz, jboolean stream, jboolean v6Only /*unused*/) {
    int fd, rv, opt=0;

    fd = NET_Socket(AF_INET6, (stream ? SOCK_STREAM : SOCK_DGRAM), 0);
    if (fd == INVALID_SOCKET) {
        NET_ThrowNew(env, WSAGetLastError(), "create");
        return -1;
    }

    rv = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &opt, sizeof(opt));
    if (rv == SOCKET_ERROR) {
        NET_ThrowNew(env, WSAGetLastError(), "create");
    }

    SetHandleInformation((HANDLE)(UINT_PTR)fd, HANDLE_FLAG_INHERIT, FALSE);

    return fd;
}