I create udp socket a wait for incoming packets, when receive any packet - create new socket, bind to the same address and connect to the client address(from recvfrom).
I can send data to this socket(client gets packets), but when client sends packets, this 'connected' socket don't get any packets, but first socket does.
The same code works well on Unix.
auto masterSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
setsockopt(masterSocket , SOL_SOCKET, SO_REUSEADDR, /* 1 */);
bind(masterSocket, {INADDR_ANY, 30000});
while (true) {
recvfrom(masterSocket, /* address */);
auto clientSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
setsockopt(clientSocket , SOL_SOCKET, SO_REUSEADDR, /* 1 */);
bind(clientSocket, {INADDR_ANY, 30000});
connect(clientSocket, /* address from recvfrom */);
send(clientSocket, /* some data */); // this works well, data is delivered to the client
int res = recv(clientSocket, /* buff */); // this stucks on windows, but returns on linux
int res = recvfrom(masterSocket, /* buff */); // this works on both windows and linux
}
This is pseudocode, I can send both client and server source if need. But problem is that program works as expected on linux, but on windows 'connected' udp socket didn't get incoming packets...