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, ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.