bind() fails with WSAEACCES

This is a discussion on bind() fails with WSAEACCES within the Tech Board forums, part of the Community Boards category; Hi, after installing some (probably wrong) device driver for my umts hardware my software written in C on WinXP always ...

  1. #1
    Registered User
    Join Date
    Nov 2006

    bind() fails with WSAEACCES


    after installing some (probably wrong) device driver for my umts hardware my software written in C on WinXP always fails at the point there it tries to bind to a multicast socket with error code WSAEACCES.

    (I'm not 100% sure that the driver is the reason, but it's installation was the last thing I did before running into that problem)

    What I tried to solve it:
    -reset tcp ip stack
    -uninstall the driver
    -try other multicast adress

    nothing seems to to help so far.

    msdn just says:

    Permission denied.


    Another possible reason for the WSAEACCES error is that when the bind function is called (on Windows NT 4 SP4 or later), another application, service, or kernel mode driver is bound to the same address with exclusive access. Such exclusive access is a new feature of Windows NT 4 SP4 and later, and is implemented by using the SO_EXCLUSIVEADDRUSE option.
    So it seems somehow this driver is accessing/locking my multicast adresses.
    Does anybody has an idea what else I could try?

    Thank you in advance!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    My impression is that multicast is a UDP protocol only. If a single receiver fails to receive a packet, there is no way to ask the sender for another copy, without really mucking up what everyone else is doing.

    To that end, you don't bind() to a port, but you use sendto() and recvfrom() instead, which supply that information as extra parameters.
    I support as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2006
    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:

    #include <winsock2.h>
    int main()
    	WSADATA wsaData;
    	WORD wVersionRequested = MAKEWORD( 2, 2 );
    	int err = WSAStartup( wVersionRequested, &wsaData );
    	if ( err != 0 ) 
    		return -1;
    	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;
    	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();
    		return -1;
    		int e = WSAGetLastError();  //e == 10013 which is WSAEACCES
    		return -1;
    if I don't set the socket option SO_REUSEADDR I get the error WSAEADDRINUSE.

    Why can't I bind?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 21
  2. Bind problem
    By moment in forum Networking/Device Communication
    Replies: 2
  3. bind() chosing a port
    By spank in forum Linux Programming
    Replies: 4
    Last Post: 04-28-2007, 10:22 AM
  4. What does bind() do, exactly?
    By Hunter2 in forum Networking/Device Communication
    Replies: 9
    Last Post: 07-07-2005, 12:12 PM
  5. Bind();
    By SirCrono6 in forum Networking/Device Communication
    Replies: 5
    Last Post: 02-26-2005, 07:01 PM
