|
|
|
@ -57,7 +57,7 @@ void Sock::sendAll(std::string to_send) {
|
|
|
|
|
else {
|
|
|
|
|
while (total_bytes_sent < str_length) {
|
|
|
|
|
/* Send the data to the 'other_socket' variable, which should be set by the client and server methods */
|
|
|
|
|
num_bytes_sent = send(this->other_socket, to_send.substr(total_bytes_sent).data(), str_length - total_bytes_sent, 0);
|
|
|
|
|
num_bytes_sent = send(this->other_socket, to_send.substr(total_bytes_sent).c_str(), str_length - total_bytes_sent, 0);
|
|
|
|
|
if (num_bytes_sent < 0) {
|
|
|
|
|
throw errno * -1;
|
|
|
|
|
}
|
|
|
|
@ -80,7 +80,9 @@ std::string Sock::recvAll() {
|
|
|
|
|
bool has_been_read = false;
|
|
|
|
|
|
|
|
|
|
if (this->protocol == ES_UDP) {
|
|
|
|
|
recvfrom(this->sock_fd, buffer, 100, 0, dest, &addrlen);
|
|
|
|
|
num_bytes_received = recvfrom(this->sock_fd, buffer, 100, 0, dest, &addrlen);
|
|
|
|
|
/* Null-terminate the string */
|
|
|
|
|
*(buffer + num_bytes_received) = '\0';
|
|
|
|
|
string.append(std::string(buffer));
|
|
|
|
|
}
|
|
|
|
|
/* For TCP sockets */
|
|
|
|
|