Networking Reference
In-Depth Information
Using Socket Topology
We have looked at basic patterns such as pipeline, publish-subscribe, request-reply,
detecting memory leaks, and also how to deal with the borderline of publish and
subscribe. In this chapter, we are going to dig deep into sockets. First, let's start
with a description of sockets.
What a socket is
Sockets are the de-facto standard API for performing network programming.
The socket API is very similar to the file I/O in many aspects since we perform
open , write , read , and close operations. They let us interact with other nodes in
the network. There are several different kinds of sockets and they have different
properties. The two most common families are:
PF_UNIX for Unix inter-process communication
PF_INET for Internet communication
However, we are going to look at DARPA Internet addresses (Internet sockets)
since the most common ZeroMQ sockets are Internet sockets.
Types of Internet sockets
There are different types of Internet sockets. You may have seen SOCK_DGRAM ,
SOCK_STREAM , and SOCK_RAW before. The following are the brief definitions of
the most popular ones:
Stream sockets ( SOCK_STREAM ): These types of sockets use Transmission
Control Protocol (TCP) or Stream Control Transmission Protocol (SCTP).
It ensures that sent data is sequenced and unduplicated and it is a reliable
socket. A sample usage would be socket(PF_INET, SOCK_STREAM, 0); .
Search MirCeyron ::

Custom Search