In this recipe, we will be creating an echo server that will listen on port
2004. Once the connection is established, the server will echo the text received back to the client.
As we did in the earlier recipes, we will encapsulate the socket, bind, and listen steps into an Objective-C class, complete with error checking to make it easy for you to add this code to your project.
This recipe is compatible with both iOS and OS X. No extra frameworks or libraries are required.
Let's get started by creating a
BSDSocketServer class that will greatly simplify the creation of a BSD socket server. While this recipe is focused on setting up an echo server, in the Creating a data server recipe of this chapter, ...