Completely rewrote Client class, and split the class into header and implementation
This commit is contained in:
@@ -2,29 +2,20 @@
|
||||
#define _CLIENT_H
|
||||
|
||||
#include "includes/sock.hpp"
|
||||
#include "includes/exception_consts.hpp"
|
||||
/*
|
||||
Client class - Inherits from 'Sock' class - Defines a TCP/UDP client. The only method that is overriden is the 'create_socket' method.
|
||||
*/
|
||||
|
||||
/* Client class - Inherits from 'Sock' class - Defines a TCP/UDP client. */
|
||||
|
||||
class Client : public Sock {
|
||||
|
||||
private:
|
||||
void create_socket() {
|
||||
Sock::create_socket();
|
||||
this->sock_fd = create_remote(this->ip_ver, this->protocol, this->address.data(), this->port, dest);
|
||||
if (sock_fd < 0) {
|
||||
if (sock_fd * -1 == ECONNREFUSED) {
|
||||
throw EXCEPT_CONNREFUSED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
Client() {}
|
||||
|
||||
Client(int ip_ver, char protocol, const char* address, int port) : Sock(ip_ver, protocol, address, port) {}
|
||||
|
||||
void create_socket() override;
|
||||
|
||||
void sendAll(std::string to_send);
|
||||
|
||||
std::string recvAll();
|
||||
};
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user