Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why bind get a WSAEACCES error?

274 views
Skip to first unread message

bucher

unread,
Apr 8, 2008, 1:49:31 AM4/8/08
to
Hi,

In a test program I want to specify the source port of socket
connection.
The code like this. Because this is a test program, some error check
code is
omitted.

SOCKET hSocket = socket(AF_INET, SOCK_STREAM, 0);

BOOL bReuse = TRUE;
setsockopt(hSocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&bReuse,
sizeof(BOOL));

sockaddr_in bindAddr = {0};
bindAddr.sin_family = AF_INET;
bindAddr.sin_addr.s_addr = INADDR_ANY;
bindAddr.sin_port = htons(7000);
int iBindRet = bind(hSocket, (LPSOCKADDR)&bindAddr,
sizeof(bindAddr));
if (iBindRet == SOCKET_ERROR) {
printf("Bind error:%d\n", GetLastError());
}


I find if my computer dial up to internet, bind will fail with error
code
WSAEACCES, otherwise bind success. What's the reason? I can't bind a
socket
to an internet address?

Thanks,

bucher

David Schwartz

unread,
Apr 16, 2008, 5:52:47 AM4/16/08
to
On Apr 7, 10:49 pm, bucher <bucher...@tom.com> wrote:

> I find if my computer dial up to internet, bind will fail with error
> code
> WSAEACCES, otherwise bind success. What's the reason? I can't bind a
> socket
> to an internet address?

Most likely, you have some kind of firewall installed and enabled.

DS

0 new messages