Exemplo n.º 1
0
int network_udp_sendv(UDPsocket udp, UDPpacket** packets, int amount) {
        int sent = 0;
        sent = SDLNet_UDP_SendV(udp, packets, amount);
        if (sent == 0) {
                std::cerr << "Failed to send vector data over UDP: " << SDLNet_GetError() << "\n";
        }
        return sent;
}
Exemplo n.º 2
0
/*
* network_udp_sendv() - Send multiple data packets via UDP
* @udp: the socket to send the data through
* @packets: a pointer to an array of packet data
* @amount: the amount of packets in the array
*/
int network_udp_send_vector(UDPsocket udp, UDPpacket** packets, int amount) {
	int sent = 0; // Define how many total packets were sent to each destination

	sent = SDLNet_UDP_SendV(udp, packets, amount); // Attempt to send the data
	if (sent == 0) { // If none of the data could be sent to anyone
		std::cerr << "Failed to send vector data over UDP: " << SDLNet_GetError() << "\n"; // Output the error message
		return 0; // Return 0 on failure
	}

	return sent; // Return how many packets were sent in total on success
}
Exemplo n.º 3
0
int SDLNet_UDP_Send(UDPsocket sock, int channel, UDPpacket *packet)
{
    /* This is silly, but... */
    packet->channel = channel;
    return(SDLNet_UDP_SendV(sock, &packet, 1));
}