| boraciner |
Sep 12th, 2006 2:42 AM |
web page - internet connection [Error] :(
I found these codes somewhere.. It takes a website adress and makes "index.html" after copied these source codes from the adress..but I can't compile it..
please help me..
:
#include <windows.h>
#include <winsock.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
FILE *html;
int syc=0;
char buf[]="GET\n\n";
unsigned char gelenveri[1000];
char adres[50];
char myadres[50];
WSADATA wsdata;
SOCKET s;
struct hostent *he;
struct sockaddr_in their_addr;
//#############################################################################
HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
WORD wOldColorAttrs;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
GetConsoleScreenBufferInfo(h, &csbiInfo);
wOldColorAttrs = csbiInfo.wAttributes;
SetConsoleTextAttribute ( h, FOREGROUND_GREEN |FOREGROUND_INTENSITY| 50);
printf ("--------------------------------------------------------------------\n" );
SetConsoleTextAttribute ( h, FOREGROUND_RED | FOREGROUND_INTENSITY | 50); //FOREGROUND_INTENSITY );
printf ("--------------------------- bycodec loader -------------------------\n" );
//SetConsoleTextAttribute ( h, wOldColorAttrs);
SetConsoleTextAttribute ( h, FOREGROUND_GREEN | FOREGROUND_INTENSITY | 50);
printf ("------------------------- by-codec@hotmail.com ---------------------\n\n\n" );
SetConsoleTextAttribute ( h, FOREGROUND_RED | FOREGROUND_INTENSITY );
//#############################################################################
WSAStartup(MAKEWORD(2,0),&wsdata);
printf(" hostname : ");
SetConsoleTextAttribute ( h, FOREGROUND_GREEN | FOREGROUND_INTENSITY );
scanf("%s",myadres);
html = fopen("index.html","w");
if((he = gethostbyname(myadres))== NULL){
printf("gethostbyname error !!!");
system("pause");
exit(-1);
}
their_addr.sin_family = AF_INET;
their_addr.sin_port = htons(80);
their_addr.sin_addr = *((struct in_addr *)he->h_addr);
memset(&(their_addr.sin_zero),'\0',8);
s=socket(AF_INET,SOCK_STREAM,0);
if(s<0){
printf("soket hatasi");
system("pause");
exit(-1);
}
if((connect(s,(struct sockaddr *)&their_addr,sizeof(struct sockaddr))) == -1){
printf("baglanti hatasi\n\n");
system("pause");
exit(-1);
} //
if((send(s,buf,strlen(buf),0))== -1){
printf("veri gönderme hatasi");
system("pause");
exit(-1);
}
SetConsoleTextAttribute ( h, FOREGROUND_BLUE | FOREGROUND_INTENSITY );
printf("\n\n\n\n");
printf("###########################################################################\n\n");
for(;;){
if((recv(s,gelenveri,1000,0)) == 0){
fclose(html);
WSACleanup();
printf("\n\n\n\n\n");
SetConsoleTextAttribute ( h, FOREGROUND_RED | FOREGROUND_INTENSITY );
printf("program basarIyLa sonlandI\nindex.html yaratILdI...\CIkmak icin bi tusa basIn ");
SetConsoleTextAttribute ( h, FOREGROUND_BLUE | FOREGROUND_INTENSITY );
printf("\n\n\n\n");
printf("###########################################################################\n\n");
getch();
exit(-1);
}
//-------------------------- </HTML>
//--------------------------
fputs(gelenveri,html);
SetConsoleTextAttribute ( h, FOREGROUND_GREEN | FOREGROUND_INTENSITY | 45 );
printf("%s",gelenveri);
memset(gelenveri,'\0',1000);
}
return 0;
}
DevCpp
:
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Documents and Settings\Ciner\Desktop\bycodec\bycodecserver.cpp" -o "C:\Documents and Settings\Ciner\Desktop\bycodec\bycodecserver.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:\Documents and Settings\Ciner\Desktop\bycodec\bycodecserver.cpp: In function `int main()':
C:\Documents and Settings\Ciner\Desktop\bycodec\bycodecserver.cpp:86: error: invalid conversion from `unsigned char*' to `char*'
C:\Documents and Settings\Ciner\Desktop\bycodec\bycodecserver.cpp:86: error: initializing argument 2 of `int recv(SOCKET, char*, int, int)'
C:\Documents and Settings\Ciner\Desktop\bycodec\bycodecserver.cpp:91:11: warning: unknown escape sequence '\C'
C:\Documents and Settings\Ciner\Desktop\bycodec\bycodecserver.cpp:102: error: invalid conversion from `unsigned char*' to `const char*'
C:\Documents and Settings\Ciner\Desktop\bycodec\bycodecserver.cpp:102: error: initializing argument 1 of `int fputs(const char*, FILE*)'
Execution terminated
Borland Shows more than that...
:(
|