of cause, I had connected to the wifi.
Thanks for your suggestion.
Code: Select all
int http(void)
{
// http request
char Cmd[512]="GET /index.html http/1.1\r\n\
Host:www.acgclub.com\r\n\
Accept:*/*\r\n\
User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt; DTS Agent;)\r\n\
Connection:Keep-Alive\r\nCache-Control: no-cache\r\n\r\n";
int HTTPSocket; // http socket
struct sockaddr_in BindSocket;
char temp[512];
int bReturn;
// socket
pspprintf(" create socket\n");
HTTPSocket=socket(PF_INET, SOCK_STREAM, 0);
if(HTTPSocket < 0)
{
pspprintf("Error when socket");
return 0;
}
//
BindSocket.sin_addr.s_addr = inet_addr ("61.152.94.145"); // www.acgclub.com
BindSocket.sin_family=AF_INET;
BindSocket.sin_port=htons(80);
//
pspprintf("connect\n");
if (connect(HTTPSocket, (struct sockaddr *)&BindSocket, sizeof(BindSocket))<0)
{
close(HTTPSocket);
pspprintf("connect failed");
return 0;
}
//送http request
pspprintf("%s", Cmd);
pspprintf("\n\n");
if(send(HTTPSocket, Cmd, strlen(Cmd), 0) <0)
{
close(HTTPSocket);
pspprintf("send http header request failed\n");
return 0;
}
pspprintf("http header\n");
///get http http header
bReturn=GetHttpHeader(HTTPSocket,temp);
if(!bReturn)
{
close(HTTPSocket);
pspprintf("get http header failed\n");
return 0;
}
pspprintf("ok\n");
pspprintf("%s", temp);
close(HTTPSocket);
return 1;
}