Implementing a POSIX socket wrapper class

Let's design and implement a class that will serve as the starting point for network-based applications. The main interface of the class looks as follows:

class Networking{public:  void start_server();public:  std::shared_ptr<Networking> get_instance();  void remove_instance();private:  Networking();  ~Networking();private:  int socket_;  sockaddr_in server_;  std::vector<sockaddr_in> clients_;private:  static std::shared_ptr<Networking> instance_ = nullptr;  static int MAX_QUEUED_CONNECTIONS = 1;};

It's natural for the Networking class to be a singleton because we want a single instance to listen for incoming connections. It's also important to have multiple objects, each of which represents a separate connection ...

Get Expert C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.