winsock error 10049

I have the following code:
LPHOSTENT hostEntry;

hostEntry = gethostbyname("www.google.com");

SOCKET listeningSocket;

listeningSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

SOCKADDR_IN serverInfo;

serverInfo.sin_family = AF_INET;
serverInfo.sin_addr = *((LPIN_ADDR)*hostEntry->h_addr_list);
serverInfo.sin_port = htons(80);
nret = bind(listeningSocket, (LPSOCKADDR)&serverInfo, sizeof(struct sockaddr));

And here is when i get the error. It means "Cannot assign requested address.". I tried to disable both firewall and avast antivirus, no reslut. I also tried to change port number, as 80 stands for browser applications and is blocked by some antivirus as unauthorised browsers, no help. What should i do to get rid of this error?
Is there a way to check whether is something blocking outgoing and incoming connections? Becouse i suspect turning firewall and avast services off might not be enough...
trick: use localhost... im more than sure, that you won´t be able to bind your own server to google^^... btw... I suggest You using getaddrinfo since gethostbyname is obsolete...

do you try to connect to google or to bind YOUR machines´port to it?... (if last, why?)...
Thx for answer. I try to bind becouse i'm not actualy writing a program, but learning the principles of network programming, so i might do something wrong, like this one :)
Last edited on
which book did u try to learn from? burn it! xD...

try the msdn and beej.us
It's not a book, it's some outdated tuttorial :)
Topic archived. No new replies allowed.