Working with Asynchronous TCP Sockets
Just as we did in Chapter 5, Writing a Server the Old-Fashioned Way, we’re going to write a simple TCP echo server that accepts connections, reads strings from the connected socket, and writes back the same message in response. Although it’s about as simple as a network protocol gets, this scenario is enough for us to exercise all the essential API calls we need to make a libuv server work. And as you’ll see, there’s a close correspondence between these calls and those you learned when we created our blocking server.
Accepting Connections
To receive connections on a server, we have to initialize the socket, bind to a port, listen for incoming connections, and then accept each incoming connection before ...
Get Modern Systems Programming with Scala Native now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.