3 void SendMessage(UDPsocket sock
, IPaddress address
, ProtocolMessage m
) {
8 .maxlen
= sizeof(ProtocolMessage
),
13 if(!SDLNet_UDP_Send(sock
, -1, &packet
)) {
14 SDL_Log("Messge not sended: %s\n", SDLNet_GetError());
19 bool RecvMessage(UDPsocket sock
, IPaddress
* address
, ProtocolMessage
* m
) {
23 .len
= sizeof(ProtocolMessage
),
24 .maxlen
= sizeof(ProtocolMessage
),
26 .address
= (IPaddress
) { 0, 0 },
30 status
= SDLNet_UDP_Recv(sock
, &packet
);
37 *address
= packet
.address
;
42 SDL_Log("Messge not received: %s\n", SDLNet_GetError());
48 bool WaitMessage(UDPsocket sock
, IPaddress
* address
, ProtocolMessage
* m
, uint32_t timeout
) {
49 uint32_t lastTime
= SDL_GetTicks();
50 while(SDL_GetTicks() - lastTime
< timeout
) {
51 if(RecvMessage(sock
, address
, m
))