i'm trying to receive data on a UDP socket, but I cant find a way to receive anything.
I can see with wireshark that the data is actually coming to the computer, but recvfrom always timeout.
The involved code is pretty simple :
mUDPSocket = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
if( mUDPSocket == INVALID_SOCKET )
return 1;
uint32_t aTimeout = 5000;
const int lResult = setsockopt( mUDPSocket, SOL_SOCKET, SO_RCVTIMEO, ( char * )&aTimeout, sizeof( aTimeout ) );
if( SOCKET_ERROR == lResult )
return 1;
struct sockaddr_in addr = {};
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl( INADDR_ANY ); //also tried with my local ip
addr.sin_port = htons( 48640 );
if( bind( mUDPSocket, ( const sockaddr * )&addr, sizeof( addr ) ) < 0 )
return 1;
And later when trying to receive data
if(recvfrom( mUDPSocket, ( char * )aData, aSize, 0, NULL, 0 )<0) //function return -1
std::cout << WSAGetLastError() << std::endl; //10060
Im trying to do something basic, so I guess im missing something simple.
Edit : the packet is sent several time by second and the timeout is 5second, so I should receive it before the real timeout

WSAETIMEDOUT. you yourself set some timeoutaTimeouton socket and it expired before you got any datagram - RbMmlResultwhenrecvfrom()exits? How isLAST_ERRORbeing set? Please provide a minimal reproducible example, and the actual Wireshark capture (or a screenshot of it) showing the details of the datagram thatrecvfrom()is not receiving. Just because a packet arrives on the machine does not guarantee it gets routed to an active socket. - Remy LebeauWSALastError()unless there was am error. Was there? - user207421