Skip to content

Conversation

@TangoBravo64
Copy link
Contributor

Fix: Library exits on "socket 0" error, #9

Contains two commits. The first fixes the actual problem (socket 0).

The second is a suggestion to avoid using "exit" in the libraries - and adds a return code and protective checks instead.

Only negative numbers indicate an error. 0 is a normal socket, and usually
just the first socket to be created.

Fixes: starnight#9
Copy link
Owner

@starnight starnight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for you PR. The idea seems good.

However, left the coding style review comment. Besides, callers of HTTPServerInit() must handle the returned error from HTTPServerInit(). Otherwise, the application will be on weird state.

Using "exit" in a library isn't too great, depending on the application.
In an embedded environment, where the application may have other functions,
it's better to just return an error.

Removes the use of "exit". Adds a return status to HTTPServerInit. Also
adds protective checks in HTTPServerRun and HTTPServerClose, if these
were called, despite HTTPServerInit failing (so socket was invalid).

See: starnight#9
@starnight starnight merged commit e70d9c7 into starnight:master Jan 18, 2026
2 checks passed
@TangoBravo64 TangoBravo64 deleted the upstream branch January 18, 2026 10:49
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

Successfully merging this pull request may close these issues.

2 participants