diff --git a/Posix/Participant.cpp b/Posix/Participant.cpp index 8d034cb..f92ba42 100644 --- a/Posix/Participant.cpp +++ b/Posix/Participant.cpp @@ -92,11 +92,10 @@ void Participant::Receive() { bool Participant::Send(RemoteParticipant* remoteParticipant, int bufferSize) { #if defined(__unix__) || defined(__APPLE__) - // Set up the destination address - // char ip_str[INET_ADDRSTRLEN]; - // inet_ntop(AF_INET, &(remote_addr.sin_addr), ip_str, INET_ADDRSTRLEN); - std::cout << "Send to " << ip_str << ":" << ntohs(remote_addr.sin_port) - << "\n"; + // std::cout << "Send to " << remoteParticipant->ipAddress << ":" << ntohs(remoteParticipant->port) + // << "\n"; + + // Set up the destination address struct sockaddr_in dest_addr; memset(&dest_addr, 0, sizeof(dest_addr)); dest_addr.sin_family = AF_INET; @@ -104,9 +103,9 @@ bool Participant::Send(RemoteParticipant* remoteParticipant, int bufferSize) { dest_addr.sin_addr.s_addr = inet_addr(remoteParticipant->ipAddress); // Send the message - int sent_bytes = sendto(sock, this->buffer, bufferSize, 0, (struct sockaddr*)&remote_addr, sizeof(remote_addr)); + int sent_bytes = sendto(sock, this->buffer, bufferSize, 0, (struct sockaddr*)&dest_addr, sizeof(dest_addr)); if (sent_bytes < 0) { - std::cerr << "sendto failed with error: " << sent_bytes << std::endl; + std::cerr << "sendto failed with error: " << sent_bytes << " " << strerror(errno) << std::endl; close(sock); return false; }