You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ip-sockets-cpp-lite is a fast, header-only, dependency-free, cross-platform C++ library that makes programming UDP/TCP sockets and working with IPv4/IPv6 addresses as easy as possible.
7
+
It's a fast, header-only, dependency-free, cross-platform C++ library that makes programming UDP/TCP sockets and working with IPv4/IPv6 addresses as easy as possible.
6
8
Forget about endless `getaddrinfo` calls, confusion with `sockaddr_in`/`sockaddr_in6`, and platform-specific workarounds.
You might wonder: "Why this library provide synchronous sockets with timeouts instead of async I/O?"
229
+
230
+
Great question! Here's why this design choice makes sense:
231
+
232
+
### ✅ Cross-platform simplicity
233
+
Async I/O APIs differ dramatically between platforms (epoll on Linux, kqueue on BSD, IOCP on Windows).
234
+
By choosing synchronous operations with timeouts, this library get a **single codebase** that works everywhere without #ifdef hell.
235
+
236
+
### ✅ Easy to understand and use
237
+
No callbacks, no event loops, no complex state machines. Your code reads linearly:
238
+
```cpp
239
+
sock.open(server);
240
+
sock.send(request);
241
+
sock.recv(response); // blocks until data arrives or timeout
242
+
```
243
+
Every developer understands this flow instantly.
244
+
245
+
### ✅ Threads are cheap, complexity is expensive
246
+
Spawning a thread to wait for socket I/O is perfectly fine:
247
+
```cpp
248
+
std::thread([&]() {
249
+
while (true) {
250
+
int bytes = server.recvfrom(buffer, sizeof(buffer), client);
251
+
if (bytes > 0) handle_client(client, buffer, bytes);
252
+
}
253
+
}).detach(); // One thread per socket — no problem!
254
+
```
255
+
Modern systems handle thousands of threads easily. **Don't optimize prematurely** — clean code is better than complex async machinery.
256
+
257
+
### ✅ Perfect for 95% of use cases
258
+
- REST API clients
259
+
- IoT devices
260
+
- Game servers
261
+
- Protocol implementations
262
+
- Embedded systems
263
+
264
+
For the 5% that truly need massive concurrency (10k+ connections), you can still use this library in thread pools or combine it with higher-level async frameworks.
265
+
266
+
---
267
+
268
+
**Bottom line:** This library gives you predictable, blocking I/O with configurable timeouts — the simplest model that works for most real-world applications. Keep it simple, keep it portable! 🎯
269
+
270
+
---
271
+
156
272
## Features 🔧
157
273
158
274
### IP Address Handling (`ip_address.h`)
@@ -161,6 +277,9 @@ sock.send("Hello", 5);
161
277
- Network prefixes and masks
162
278
- IPv4-over-IPv6 mapping
163
279
- Address + port as a single unit
280
+
- Zero-copy overlay on existing memory buffers
281
+
- Rich constructors from strings, numbers, bytes
282
+
- Flexible parsing of various formats (hex, decimal, dotted)
0 commit comments