🟨 Synchronous socket networking and DNS lookup
SaneCppSocket.h is a library implementing synchronous socket networking and DNS lookup.
| Class | Description |
|---|---|
| SC::SocketDescriptor | Low-level OS socket handle. |
| SC::SocketServer | Use a SocketDescriptor as a Server (example TCP or UDP Socket Server). |
| SC::SocketClient | Use a SocketDescriptor as a client (example a TCP or UDP socket client). |
| SC::SocketIPAddress | Native representation of an IP Address. |
| SC::SocketDNS | Synchronous DNS Resolution. |
| SC::SocketNetworking | Networking globals initialization (Winsock2 WSAStartup) |
🟨 MVP
Simple synchronous TCP client / server workflow is supported, but it would need better testing.
Some relevant blog posts are:
It also allow querying inheritability and changing it (and blocking mode)
Example (extracted from unit test):
Example:
The socket client can be obtained via SC::SocketServer::accept or connected to an endpoint through SC::SocketClient::connect.
Example (accepted client from server, doing a synchronous read):
Example (connecting client to server, doing two synchronous writes):
Example:
Example:
🟩 Usable
🟦 Complete Features:
💡 Unplanned Features:
LOC counts exclude comments. Library counts files physically under Libraries/Socket. Single File counts SaneCppSocket.h. Standalone counts SaneCppSocketStandalone.h and intentionally includes dependency payloads.
| Metric | Header | Source | Sum |
|---|---|---|---|
| Library | 185 | 894 | 1079 |
| Single File | 1158 | 1080 | 2238 |
| Standalone | 1158 | 1080 | 2238 |