mirror of
https://github.com/Kiritow/wg-ops.git
synced 2024-03-22 13:11:37 +08:00
Fix recv problem
This commit is contained in:
parent
6c46cab599
commit
c334176f3c
22
w2u.c
22
w2u.c
|
@ -120,26 +120,28 @@ int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if (events[i].data.fd == listener)
|
if (events[i].data.fd == listener)
|
||||||
{
|
{
|
||||||
int nsize = recvfrom(listener, buffer, sizeof(buffer), 0, NULL, NULL);
|
int nsize;
|
||||||
|
while((nsize = recvfrom(listener, buffer, sizeof(buffer), 0, NULL, NULL)) > 0) {
|
||||||
if (nsize < 0) {
|
|
||||||
perror("recvfrom");
|
|
||||||
} else {
|
|
||||||
sendto(sender, buffer, nsize, 0, (const struct sockaddr*)(addrTargets + rrOffset), sizeof(struct sockaddr_in));
|
sendto(sender, buffer, nsize, 0, (const struct sockaddr*)(addrTargets + rrOffset), sizeof(struct sockaddr_in));
|
||||||
if (++rrOffset >= PORT_UR_SIZE) {
|
if (++rrOffset >= PORT_UR_SIZE) {
|
||||||
rrOffset = 0;
|
rrOffset = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nsize < 0 && errno != EAGAIN) {
|
||||||
|
perror("recvfrom: ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (events[i].data.fd == sender)
|
else if (events[i].data.fd == sender)
|
||||||
{
|
{
|
||||||
int nsize = recvfrom(sender, buffer, sizeof(buffer), 0, NULL, NULL);
|
int nsize;
|
||||||
|
while((nsize = recvfrom(sender, buffer, sizeof(buffer), 0, NULL, NULL)) > 0) {
|
||||||
if (nsize < 0) {
|
|
||||||
perror("recvfrom");
|
|
||||||
} else {
|
|
||||||
sendto(listener, buffer, nsize, 0, (const struct sockaddr*)&addrWg, sizeof(struct sockaddr_in));
|
sendto(listener, buffer, nsize, 0, (const struct sockaddr*)&addrWg, sizeof(struct sockaddr_in));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nsize < 0 && errno != EAGAIN) {
|
||||||
|
perror("recvfrom: ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user