Ejemplo n.º 1
0
int network_udp_bind(UDPsocket udp, int channel, IPaddress* ipa) {
        network_udp_reopen(udp, 0);
        int c = SDLNet_UDP_Bind(udp, channel, ipa);
        if (c == -1) {
                std::cerr << "Failed to bind UDP on channel " << channel << ": " << SDLNet_GetError() << "\n";
        }
        return c;
}
Ejemplo n.º 2
0
/*
* network_udp_bind() - Bind the given socket to the given IP address data using the given channel
* @udp: the socket to bind
* @channel: the channel to use, set it to -1 in order to use the first available channel
* @ipa: the IP address data
*/
int network_udp_bind(UDPsocket* udp, int channel, IPaddress* ipa) {
	network_udp_reopen(udp, network_get_port(ipa->port)); // Reset the socket in case it was previously bound

	int c = SDLNet_UDP_Bind(*udp, channel, ipa); // Attempt to bind the socket to the given IP address
	if (c == -1) { // If the socket failed to bind
		std::cerr << "Failed to bind UDP on channel " << channel << ": " << SDLNet_GetError() << "\n"; // Output the error message
	}

	return c; // Return the channel on success, or -1 on failure
}