|
-
March 10th, 2003, 12:31 PM
#1
winsock, getting the html for a simple web site?
Well this is a problem I can't fix!..might have something to do with IP6 god know!...but would appreciate some feedback on it..
Now, using a simple winsock piece of code...I can get the html text from www.google.com, yahoo.com etc...and it works...
but for a few web sites...e.g. "www.xbdev.net" it won't give me the html...it gives me an error message!...now if I use GetHostByName on xbdev.net...I can get the ip : 212.78.206.150 ....but if I type it in the IE browser it won't show the web page ..hmmm
Now the code can't get any more simple!...and as I said it works for www.google.com come...but not for xbdev.net ;(
Really appreciate any ideas...its a brain problem.
char aa[1000]; //big buffer
d = WSAStartup( 0x101, &ws);
//PART -2-
s=socket(AF_INET, SOCK_STREAM, 0);
sprintf(aa, "SOCKET=%d", s);
if(bDebug)
abc(aa);
a.sin_family = AF_INET;
a.sin_port = htons(80);
struct hostent *h = gethostbyname("www.xbdev.net");
a.sin_addr.s_addr = inet_addr(inet_ntoa(*((struct in_addr *)h->h_addr)));
int d = connect(s, (struct sockaddr*)&a, sizeof(a) );
strcpy(aa, "GET / \r\n");
strcat(aa, "HTTP 1.0 \r\n\r\n");
send(s, aa, sizeof(aa), 0);
ii = 1;
strcpy(received, "");
while( ii!=0 )
{
memset(aa, '\0', sizeof(aa));
ii = recv(s, aa, 1000, 0);
printtofile(aa); // a function to print received text out as I get it.
}
WSACleanup();

Ben
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|