Fix sending on Posix
This commit is contained in:
parent
59006540e6
commit
e7990cf00a
@ -92,11 +92,10 @@ void Participant::Receive() {
|
|||||||
|
|
||||||
bool Participant::Send(RemoteParticipant* remoteParticipant, int bufferSize) {
|
bool Participant::Send(RemoteParticipant* remoteParticipant, int bufferSize) {
|
||||||
#if defined(__unix__) || defined(__APPLE__)
|
#if defined(__unix__) || defined(__APPLE__)
|
||||||
// Set up the destination address
|
// std::cout << "Send to " << remoteParticipant->ipAddress << ":" << ntohs(remoteParticipant->port)
|
||||||
// char ip_str[INET_ADDRSTRLEN];
|
// << "\n";
|
||||||
// inet_ntop(AF_INET, &(remote_addr.sin_addr), ip_str, INET_ADDRSTRLEN);
|
|
||||||
std::cout << "Send to " << ip_str << ":" << ntohs(remote_addr.sin_port)
|
// Set up the destination address
|
||||||
<< "\n";
|
|
||||||
struct sockaddr_in dest_addr;
|
struct sockaddr_in dest_addr;
|
||||||
memset(&dest_addr, 0, sizeof(dest_addr));
|
memset(&dest_addr, 0, sizeof(dest_addr));
|
||||||
dest_addr.sin_family = AF_INET;
|
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);
|
dest_addr.sin_addr.s_addr = inet_addr(remoteParticipant->ipAddress);
|
||||||
|
|
||||||
// Send the message
|
// 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) {
|
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);
|
close(sock);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user