Made the sendAll and recvAll functions in sock.cpp use variables set by the children, rather than having the functions pass parameters

This commit is contained in:
2024-02-21 22:25:52 -05:00
parent 350b51e28b
commit 9954a18171
3 changed files with 58 additions and 26 deletions

View File

@@ -22,7 +22,7 @@ void Client::create_socket() {
Sock::create_socket();
this->sock_fd = create_remote(this->ip_ver, this->protocol, this->address.data(), this->port, dest);
if (this->sock_fd < 0) {
throw strerror(this->sock_fd * -1);
throw (this->sock_fd * -1);
}
}
@@ -32,12 +32,19 @@ client socket (TCP or UDP) does not have this requirement. Therefore, while both
sendAll methods perform the same actions, they do so using different sockets. */
void Client::sendAll(std::string to_send) {
Sock::sendAll(to_send, this->sock_fd);
this->other_socket = this->sock_fd;
Sock::sendAll(to_send);
}
/* Receives data from peer socket, and returns it. See above for better
explanation of why this method is overriden. */
std::string Client::recvAll() {
return Sock::recvAll(this->sock_fd);
this->other_socket = this->sock_fd;
return Sock::recvAll();
}
/* Returns the type of socket based on the global constants set in sock.hpp */
int Client::get_type() {
return SOCK_CLIENT;
}