diff --git a/applications/anatomy.rst b/applications/anatomy.rst index ba5185a..a93ec79 100644 --- a/applications/anatomy.rst +++ b/applications/anatomy.rst @@ -85,19 +85,20 @@ operation: The reason that this operation takes three arguments is that the socket interface was designed to be general enough to support any underlying protocol suite. Specifically, the ``domain`` argument specifies the -protocol *family* that is going to be used: ``PF_INET`` denotes the -Internet family, ``PF_UNIX`` denotes the Unix pipe facility, and -``PF_PACKET`` denotes direct access to the network interface (i.e., it -bypasses the TCP/IP protocol stack). The ``type`` argument indicates the -semantics of the communication. ``SOCK_STREAM`` is used to denote a byte -stream. ``SOCK_DGRAM`` is an alternative that denotes a message-oriented -service, such as that provided by UDP. The ``protocol`` argument -identifies the specific protocol that is going to be used. In our case, -this argument is ``UNSPEC`` because the combination of ``PF_INET`` and -``SOCK_STREAM`` implies TCP. Finally, the return value from ``socket`` -is a *handle* for the newly created socket—that is, an identifier by -which we can refer to the socket in the future. It is given as an -argument to subsequent operations on this socket. +communication domain that is going to be used: ``AF_INET`` denotes the +IPv4 Internet family, ``AF_UNIX`` denotes the Unix-domain socket family +for communication between local processes, and ``AF_PACKET`` provides +low-level access to packets at the network-device level. The ``type`` +argument indicates the semantics of the communication. ``SOCK_STREAM`` +is used to denote a byte stream. ``SOCK_DGRAM`` is an alternative that +denotes a message-oriented service, such as that provided by UDP. The +``protocol`` argument identifies the specific protocol that is going to +be used. In our case, this argument is ``0``, which selects TCP as the +default protocol for the ``AF_INET`` and ``SOCK_STREAM`` combination. +Finally, the return value from ``socket`` is a *handle* for the newly +created socket—that is, an identifier by which we can refer to the +socket in the future. +It is given as an argument to subsequent operations on this socket. The next step depends on whether you are a client or a server. On a server machine, the application process performs a *passive* open—the diff --git a/resources/code/simplex-client.c b/resources/code/simplex-client.c index 16321c1..374226a 100644 --- a/resources/code/simplex-client.c +++ b/resources/code/simplex-client.c @@ -48,7 +48,7 @@ main(int argc, char *argv[]) sin.sin_port = htons(SERVER_PORT); /* active open */ - if ((s = socket(PF_INET, SOCK_STREAM, 0)) < 0) { + if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("socket"); exit(1); } diff --git a/resources/code/simplex-server.c b/resources/code/simplex-server.c index b0fcf15..17e2299 100644 --- a/resources/code/simplex-server.c +++ b/resources/code/simplex-server.c @@ -39,7 +39,7 @@ main(int argc, char *argv[]) sin.sin_port = htons(SERVER_PORT); /* setup passive open */ - if ((s = socket(PF_INET, SOCK_STREAM, 0)) < 0) { + if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("socket"); exit(1); }