Answer the question
In order to leave comments, you need to log in
Why is the UDP client on VirtualBox-Ubuntu not receiving datagrams from the UDP-server-Windows?
My client sends a datagram to the server and waits for a response. The datagram arrives generally fine, but when the server sends a sign that it received the datagram, it does not reach the client. The client is on VirtualBox-Ubuntu. When I start the client and the server on Windows, everything is ok. Maybe there is some Linux subtlety here? Here is how I send the response back:
//приём датаграммы от клиента
int received = recvfrom(ls[i], datagram, sizeof(datagram),
0, (struct sockaddr*) &addr, &addrlen);
if (received > 0) {
//отправка датаграммы, которая говорит что всё хорошо
sendto(ls[i], datagram, 4, 0, (struct sockaddr*)&addr, sizeof(struct sockaddr_in));
//получается что я отправляю на тот же addr. Когда я запускаю клиента на винде то всё хорошо
}
Answer the question
In order to leave comments, you need to log in
while ((sel = select(s, &rfd, NULL, NULL, &time_val)) <= 0) {
res = sendto(s, dns_datagram, data_curlen, flags, (struct sockaddr*) &addr,
sizeof(struct sockaddr_in));
if (res < 0) {
printf("res = %d\nError. Server offline?\n", res);
printf("sel = %d\n", sel); // out 0
}
FD_ZERO(&rfd);
FD_SET(s, &rfd);
}
nfds This argument should be set to the highest-numbered file
descriptor in any of the three sets, plus 1 . The
indicated file descriptors in each set are checked, up to
this limit (but see BUGS).
nfds Ignored. The nfds parameter is included only for compatibility with Berkeley sockets.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question