I am creating a UDP socket (AF_INET
, SOCK_DGRAM
, IPPROTO_UDP
) via Winsock and trying to recvfrom
on this socket, but it a
I had the same problem a few weeks ago, the following remarks helped me to understand whether an explicit bind() call is necessary:
recvfrom function (MSDN)
Explicit binding is discouraged for client applications. For client applications using this function, the socket can become bound implicitly to a local address through sendto, WSASendTo, or WSAJoinLeaf.
sendto function (MSDN)
Note If a socket is opened, a setsockopt call is made, and then a sendto call is made, Windows Sockets performs an implicit bind function call. If the socket is unbound, unique values are assigned to the local association by the system, and the socket is then marked as bound.