Repository navigation
fix(windows): start Winsock at the first socket; 0.3.5 never did - #26
Merged
Merged
Conversation
…ry request failed Socket::platform_init() existed and was never called. On Windows the first connect then failed with WSANOTINITIALISED, reported as status 0 'Connection failed'. Socket::ensure_platform_started() runs once per process at the top of connect (before socket() and getaddrinfo); Socket::platform_started() reports it; tests/test_winsock_start.cpp is the first socket of its process and checks both.
Sunrisepeak
added a commit
that referenced
this pull request
Nov 30, 2026
Sunrisepeak
added a commit
to Sunrisepeak/xgit
that referenced
this pull request
Nov 30, 2026
…s now - tinyhttps 0.3.6 starts Winsock at the first socket itself (mcpplibs/tinyhttps#26), so the transport no longer does it on the library's behalf. - src/sha256.cppm wraps mcpplibs.mwrap.mbedtls (the wrap opened from this work, now in the index as mcpplibs/mcpp-index#935) instead of its own FIPS 180-4 arithmetic; the known-answer tests stay as they were. - compat.mbedtls is one version for the graph, 3.6.8 (the wrap's; tinyhttps asks for 3.6.1, and two versions of a C source package cannot share one build).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Socket::platform_init()(WSAStartup) existed and was never called anywhere in the library. On Windows the firstconnecttherefore ransocket()/getaddrinfo()with Winsock unstarted: every request ended instatusCode = 0,statusText = "Connection failed", with nothing saying why. A program that uses the library as documented cannot make a single request on Windows.Change
Socket::ensure_platform_started()— once per process, called at the top ofSocket::connect, before the firstsocket()orgetaddrinfo().Socket::platform_started()— says whether it ran.tests/test_winsock_start.cpp— a program whose first socket is the test's own:platform_started()is false, then aconnectto the loopback's port 1 (refused at once by a started Winsock) makes it true. Runs on every platform; the flag semantics are the same, theWSAStartupis Windows-only.platform_init()stays as it was (public API).Verification
mcpp test winsock_starton Windows (clang 23.1.3, MSVC STL):test_winsock_start ... ok.Socket::platform_init()itself, turned "Connection failed" on every request into real answers (401/403 from api.github.com) in gitxxx before this PR; this PR moves it where it belongs.Authorship: ai-and-human