recv()

This is used to receive a message from the connected socket. The socket may be in connection mode or connectionless mode. Here is its syntax:

ssize_t recv(int fdsock, void *buf, size_t len, int flags);

Here, fdsock represents the file descriptor of the socket from which the message has to be fetched, buf represents the buffer where the message that is received is stored, len specifies the length in bytes of the buffer that's pointed to by the buf argument, and flags specifies the type of message being received. Usually, its value is kept at 0.

We can now begin with the first part of this recipe how to send data to the client.