@@ -58,3 +58,37 @@ Actually at first I wanted to avoid `std::string` because they incur unneeded bu
That initial implementation remains available in branch `string`.
## Echo Server and Client
Using [Beej's Guide to Network Programming](https://beej.us/guide/bgnet/html//index.html) as a handy reference, I wrote adapters for needed parts of the POSIX socket API. As much as practical, these adapters mirror [Python's socket API](https://docs.python.org/3/library/socket.html).
These adapters include the functions:
-`getaddrinfo`
-`socket`
-`setsockopt` (only for options with integer values, which is all I needed)
-`connect`
-`bind`
-`listen`
-`accept`
-`recv`
-`send`
-`shutdown`
-`close`
The new GIL-free strings proved very useful for this :)
Since currently Cython+ doesn't have GIL-free exceptions (also in our next steps), I take the GIL and raise Python exceptions instead when there is an error.
It's not complete, but it's enough to write a simple echo server and client demo: