Skip to content

Initialize Winsock before the host transports open a socket - #213

Merged
kahrendt merged 1 commit into
mainfrom
chrisuthe/winsock-init
Oct 28, 2026
Merged

kahrendt merged 1 commit into
mainfrom
chrisuthe/winsock-init

Conversation

@chrisuthe

Copy link
Copy Markdown
Member

On Windows every socket call fails until WSAStartup() runs, and IXWebSocket leaves that to the application through ix::initNetSystem(). The client could neither dial a server ("Either the application has not called WSAStartup") nor listen.

Summary

  • SendspinWsServer::start() and SendspinClientConnection::start() call ix::initNetSystem() once, through a function-local static, before their first socket. It is never undone; Windows releases it at process exit.
  • The two handle a failure differently on purpose. The server's start() returns a bool, so it logs and returns false. The client's start() has no failure return, so it logs and lets the attempt go ahead; its first socket call then fails and IXWebSocket reports it as the connection's Error, which already reports the close.

Notes

Testing

  • Windows 11, clang-cl 22.1.3 (from Fix what running on Windows turns up #211): basic_client dials Music Assistant with -u and listens on its own port; before this change both failed with the WSAStartup error.
  • Linux, GCC 16: host build clean; sendspin_tests all pass. The ASan/UBSan and TSan runs are this PR's CI (no sanitizer runtime on the local machine).

@kahrendt kahrendt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks

@kahrendt
kahrendt merged commit b0fcf5b into main Oct 28, 2026
16 checks passed
@kahrendt
kahrendt deleted the chrisuthe/winsock-init branch October 28, 2026 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants