Skip to content

S13.09: WinsockTcpStream — Windows TCP transport #135

Description

@DavidCozens

Parent epic: #40

Goal

Implement a Winsock TCP stream (SolidSyslogWinsockTcpStream) using winsock2.h, providing the SolidSyslogStream interface. The Windows TCP path mirrors SolidSyslogPosixTcpStream (extracted in S13.08 and hardened in S12.08) with platform-appropriate type and error-handling adjustments.

Acceptance criteria

  • Platform/Windows/Interface/SolidSyslogWinsockTcpStream.h — Create/Destroy, SolidSyslogWinsockTcpStreamStorage, SOLIDSYSLOG_WINSOCK_TCP_STREAM_SIZE
  • Platform/Windows/Source/SolidSyslogWinsockTcpStream.c — implementation using socket, connect, send, recv, closesocket, setsockopt (TCP_NODELAY + SO_SNDTIMEO)
  • Platform/Windows/Source/SolidSyslogWinsockTcpStreamInternal.h — UT_PTR_SET test seam with WinsockTcpStream_* namespaced forwarders (avoids colliding with Winsock_socket/Winsock_closesocket already exported by SolidSyslogWinsockDatagram)
  • Tests/Support/WinsockFake.{h,c} extended with connect, send, recv, setsockopt fakes plus configuration knobs (mirrors S12.08 SocketFake additions)
  • Tests/SolidSyslogWinsockTcpStreamTest.cpp — port of SolidSyslogPosixTcpStreamTest.cpp adjusted for Winsock (no EINTR retry, flags = 0 instead of MSG_NOSIGNAL, generic send-error in place of EAGAIN-specific test)
  • CMake: sources added when SOLIDSYSLOG_WINSOCK is true; library already links ws2_32
  • All CI checks green including windows-build-and-test
  • Caller manages WSAStartup / WSACleanup — documented as precondition (matches existing Winsock pattern)

Prep refactor (same branch, separate commit)

SOLIDSYSLOG_TCP_DEFAULT_PORT and SOLIDSYSLOG_UDP_DEFAULT_PORT consolidated into Core/Interface/SolidSyslogTransport.h so the new Winsock TCP stream does not duplicate the constant. Both are platform-agnostic IANA/RFC facts and naturally pair with the SolidSyslogTransport enum already in that header. SolidSyslogUdpSender.h, SolidSyslogPosixTcpStream.h, and the new SolidSyslogWinsockTcpStream.h #include "SolidSyslogTransport.h" so existing callers continue to get the constants transitively.

Design decisions

  • Implements the SolidSyslogStream interface extracted in S13.08 (S13.08: Extract Stream abstraction, provide PosixTcpStream #134); production logic mirrors PosixTcpStream after the S12.08 error-edge work
  • SOCKET (unsigned UINT_PTR) instead of int; INVALID_SOCKET instead of -1; closesocket() instead of close(); Winsock send/recv return int instead of ssize_t
  • SO_SNDTIMEO: DWORD milliseconds on Winsock instead of POSIX struct timeval; same level/optname so tests can assert on the pair via HasSetSockOpt
  • EINTR retry path pruned — Winsock send() has no signal-interruption semantics
  • MSG_NOSIGNAL removed — Winsock does not generate SIGPIPE, flags pass as 0
  • No WSAGetLastError() needed — vtable contract is bool; caller already handles "false → close + reconnect → store-and-forward replays" identically to PosixTcpStream
  • Test seam follows the WinsockDatagram / WinsockResolver precedent (UT_PTR_SET on file-scope function-pointer forwarders) but uses WinsockTcpStream_* namespaced symbols to avoid linker collisions with the un-namespaced Winsock_* already exported by WinsockDatagram
  • No #ifdef in source files — platform differences handled entirely in CMake

Out of scope (deferred to S13.10)

  • Wiring TCP into Example/Windows/SolidSyslogWindowsExample.c
  • BDD scenario for Windows TCP delivery to syslog-ng
  • End-to-end exercise via windows-build-and-test

Context

Completes the Windows TCP transport path. Combined with WinsockResolver (S13.04) and the Stream abstraction (S13.08), this enables TCP syslog delivery on Windows. S13.10 then proves the path end-to-end against syslog-ng in BDD and wires it into the Windows example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    storyStory issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions