You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
708 B
C++

#include "sock.hpp"
/*
Server class - Defines a TCP/UDP server.
- The constructor takes in a **local** address and port, and creates a listening socket on that address/port.
*/
class Server : public Sock {
private:
void create_socket() {
Sock::create_socket();
this->sock_fd = create_local(this->ip_ver, this->protocol, this->address.data(), this->port, dest);
if (sock_fd < 0) {
if (sock_fd * -1 == ECONNREFUSED) {
throw EXCEPT_CONNREFUSED;
}
}
}
public:
Server() {}
Server(int ip_ver, char protocol, const char* address, int port) : Sock(ip_ver, protocol, address, port) {}
/* TODO - Add comments to better explain the inheritance and polymorphism going on */
};