Commit graph Crafter.Network/implementations/Crafter.Network-ClientTCP.cpp
Author SHA1 Message Date
catbot
b758419007 fix(tcp): resolve, connect, bind and send failures were silent or wrong
The HTTP/1.1 stack sits directly on these two classes and each of these
bit it:

- gethostbyname() returning null on an unresolvable host was dereferenced
  straight into a crash, and it is not thread safe; use getaddrinfo.
- A failed socket()/connect() only printed to stderr and handed back an
  unusable ClientTCP, so the real error surfaced much later as an
  unrelated errno from send().
- send() was assumed to accept everything it was offered. It does not
  once a buffer outgrows the socket's send buffer, which silently
  truncated multi-megabyte bodies. Loop, and pass MSG_NOSIGNAL so a
  vanished peer raises EPIPE instead of killing the process.
- ClientTCP's move constructor closed the socket it had just taken
  ownership of, and both it and the destructor tested `socketid != 1`
  where they meant `!= -1`.
- ListenerTCP ignored bind()'s result, leaving a listener that accepted
  nothing with no explanation, and did not set SO_REUSEADDR, so a
  restart hit EADDRINUSE for the length of TIME_WAIT.

accept() failing during Stop() is expected and no longer logged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-27 00:44:56 +00:00
e33ec5b72e SPDX license 2026-07-22 17:55:45 +02:00
de2073422c crafter build V2 2026-05-06 01:09:40 +02:00
5bfee7f955 added readme 2025-11-03 17:52:45 +01:00
c49f947a9b fixes 2025-11-03 15:51:13 +01:00
9bdf133d0f fixes 2025-11-03 14:25:51 +01:00
0fbc5bad52 initial commit 2025-11-02 15:00:53 +01:00