O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Simple Network Programming

In networking, the terms client and server describe the party that is waiting for a new connection (the server) and the party that initiates a new connection (the client). Once the communications channel is set up, the client and server are peers that communicate with each other.

Server coding

Here is the set of calls and actions used when writing a server program:

  1. Get a socket().

  2. Construct an address–port pair that the server will listen on.

  3. bind() the socket to the address.

  4. Tell the socket to start listen()ing for new connections.

  5. accept() new connections from clients.

  6. Use read() and write() to receive and send data over the client connection.

  7. close() the client connection’s socket.

int socket (int domain, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required