Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS, windows - SDLNet_SendDatagram always returns false #115

Open
andyvand opened this issue Feb 1, 2025 · 0 comments
Open

macOS, windows - SDLNet_SendDatagram always returns false #115

andyvand opened this issue Feb 1, 2025 · 0 comments

Comments

@andyvand
Copy link

andyvand commented Feb 1, 2025

SDL3_net is used.
The SDL3 socket is created correctly.
On send SDLNet_SendDatagram returns false.
With SDL_GetError it returns this:
Failed to send from socket: Invalid argument.

Example output from OpenTyrian 2000 (adapted for SDL3):
SDLNet_SendDatagram: Failed to send from socket: Invalid argument, host: 172.16.197.130, port: 1333, length: 20 (3)

C send datagram code:
if (SDLNet_SendDatagram(socket, packet_out_temp->addr, packet_out_temp->port, packet_out_temp->buf, packet_out_temp->buflen) == false) { fprintf(stderr, "SDLNet_SendDatagram: %s, host: %s, port: %d, length: %d (3)\n", SDL_GetError(), SDLNet_GetAddressString(ip), network_opponent_port, packet_out_temp->buflen); return false; }

Code of the app:
https://github.com/andyvand/opentyrian2000/blob/master/src/network.c

I have also adapted voipchat.c for checking SDLNet_SendDatagram, result is the same:
if (SDLNet_SendDatagram(sock, server_addr, server_port, scratch_area, br + extra) == false) { SDL_Log("ERROR: Send %d datagram bytes to server %s:%d - %s", br + extra, SDLNet_GetAddressString(server_addr), (int) server_port, SDL_GetError()); }

Output under macOS:
2025-02-01 10:31:33.603 voipchat[8376:555267] CLIENT: Sending 1200 new bytes to server at 127.0.0.1:3025... 2025-02-01 10:31:33.603 voipchat[8376:555267] ERROR: Send 1200 datagram bytes to server 127.0.0.1:3025 - Failed to send from socket: Invalid argument

Output under Windows:
ERROR: Send 598 datagram bytes to server 127.0.0.1:3025 - Failed to send from socket: Het systeem heeft een ongeldig pointeradres gevonden tijdens de poging om een pointerargument te gebruiken in een aanroep.

So the problem must be in the library but I haven't found the solution yet...
It has something to do with invalid pointers.

@andyvand andyvand changed the title macOS - SDLNet_SendDatagram returns Failed to send from socket: Invalid argument macOS, windows - SDLNet_SendDatagram returns false Feb 1, 2025
@andyvand andyvand changed the title macOS, windows - SDLNet_SendDatagram returns false macOS, windows - SDLNet_SendDatagram always returns false Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant