To start, we must define the maximum buffer size we plan to send from the client to the server and back, and we must also define the port we wish to use:
#define PORT 22000#define MAX_SIZE 0x10
For the server, we will need the following includes:
#include <array>#include <iostream>#include <unistd.h>#include <string.h>#include <sys/socket.h>#include <netinet/in.h>
As with the previous examples, we will create the server using a class to take advantage of RAII:
class myserver{ int m_fd{}; int m_client{}; struct sockaddr_in m_addr{};public:
As with UDP, three member variables will be used. The first member variable, m_fd, stores the socket file descriptor for the socket associated with the server. Unlike UDP, this descriptor will not ...