SDL_net icon indicating copy to clipboard operation
SDL_net copied to clipboard

SDLNet_CreateServer: set SO_REUSEADDR

Open bog-dan-ro opened this issue 1 year ago • 0 comments

SO_REUSEADDR is needed to quickly reuse the same port after the application crash or forgets to close all connections properly.

int opt = 1;
setsockopt(server->handle, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));

just before int rc = bind(server->handle, addrwithport->ai_addr, addrwithport->ai_addrlen); will do the job.

Let me know if I shall create a PR for you.

bog-dan-ro avatar Jan 29 '24 08:01 bog-dan-ro