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.

34 lines
898 B
C++

#ifndef _SERVER
#define _SERVER
#include "includes/sock.hpp"
/* Server class - This class is used to create a TCP/UDP server.
It inherits from the 'Sock' class. */
class Server : public Sock {
public:
/* Constructors */
Server() {}
Server(int ip_ver, char protocol, const char* address, int port) : Sock(ip_ver, protocol, address, port) {}
/* Destructor */
~Server();
/* Method to create socket - overrides (i.e. extends) method from parent class */
void create_socket() override;
/* FOR TCP ONLY - Wait for a peer to connect to this socket, and store the result in 'other_socket' */
void wait_for_peer();
/* FOR TCP - Send data to the peer socket
FOR UDP - Send data to the client, from which data was received.
FOR UDP, this function MUST be called after recvAll() */
void sendAll(std::string to_send);
/* Receive data from peer socket */
std::string recvAll();
};
#endif