In either case, the server always starts up first, binds itself to a socket, and listens to messages. How the server attempts to listen depends on the type of connection for which you have programmed it. We will cover these in the following examples. You will use this socket descriptor to refer to this socket in all subsequent calls in your program. Sockets are created without a name.
Clients use the name of the socket in order to read or write to it.
This is where the bind function comes in. The first item is a socket descriptor. The second is a structure with the name to use, and the third item is the size of the structure. If your program is a server, then it sets itself up to listen and accept connections. Let's look at the function available for such an endeavor.