Sorry Salem, I didn't looked carefully enough. The code which causes the problem wasn't written by me. It has nothing to do with multi cast (which is used in another part of the program). The software is widely used and I'm the only one who suffers from that problem, it doesn't happen on any other computer.
I extracted the code and was able to reproduce it in the following example:
if I don't set the socket option SO_REUSEADDR I get the error WSAEADDRINUSE.
WORD wVersionRequested = MAKEWORD( 2, 2 );
int err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 )
unsigned short port = 8015;
unsigned int bind_addr = htonl(INADDR_ANY);
SOCKET s = socket(PF_INET, SOCK_DGRAM, 0);
struct sockaddr_in addr;
int yes = 1;
if (s < 0) return -1;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = bind_addr;
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&yes, sizeof(yes)) < 0)
int e = WSAGetLastError();
if (bind(s, (struct sockaddr*)&addr, sizeof(addr)) < 0)
int e = WSAGetLastError(); //e == 10013 which is WSAEACCES
Why can't I bind?