diff --git a/sock.cpp b/sock.cpp index 9baf171..f6daec8 100644 --- a/sock.cpp +++ b/sock.cpp @@ -55,7 +55,13 @@ void Sock::sendAll(std::string to_send) { /* For UDP sockets */ if (this->protocol == ES_UDP) { - if (sendto(this->sock_fd, to_send.data(), str_length, 0, (struct sockaddr *)dest, addrlen) == -1) { + int retval; + if (this->has_remote_address()) { + retval = send(this->sock_fd, to_send.data(), str_length, 0); + } else { + retval = sendto(this->sock_fd, to_send.data(), str_length, 0, (struct sockaddr *)dest, addrlen); + } + if (retval == -1) { throw errno; } }