C Board  

Go Back   C Board > Community Boards > Tech Board

Reply
 
LinkBack Thread Tools Display Modes
Old 02-24-2009, 12:08 PM   #1
Registered User
 
Join Date: Nov 2006
Posts: 510
bind() fails with WSAEACCES

Hi,

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:
-reboot
-reset tcp ip stack
-uninstall the driver
-try other multicast adress

nothing seems to to help so far.

msdn just says:

Quote:
Permission denied.

An attempt was made to access a socket in a way forbidden by its access permissions. An example is using a broadcast address for sendto without broadcast permission being set using setsockopt(SO_BROADCAST).

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!
pheres is offline   Reply With Quote
Old 02-24-2009, 12:49 PM   #2
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,700
http://www.sockets.com/ch16.htm#Multicast
http://beej.us/guide/bgnet/output/ht...alls.html#bind
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.
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Old 02-24-2009, 01:58 PM   #3
Registered User
 
Join Date: Nov 2006
Posts: 510
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:

Code:
#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;

	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();
		closesocket(s);
		return -1;
	}

	if (bind(s, (struct sockaddr*)&addr, sizeof(addr)) < 0)
	{
		int e = WSAGetLastError();  //e == 10013 which is WSAEACCES
		closesocket(s);
		return -1;
	}
};
if I don't set the socket option SO_REUSEADDR I get the error WSAEADDRINUSE.

Why can't I bind?
pheres is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Computer fails to detect existing hardware, even with installed drivers! Yarin Tech Board 21 06-24-2009 09:49 AM
Bind problem moment Networking/Device Communication 2 04-24-2009 11:36 AM
bind() chosing a port spank Linux Programming 4 04-28-2007 10:22 AM
What does bind() do, exactly? Hunter2 Networking/Device Communication 9 07-07-2005 12:12 PM
Bind(); SirCrono6 Networking/Device Communication 5 02-26-2005 08:01 PM


All times are GMT -6. The time now is 07:07 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22