Linux Socket HTTPÇëÇóµÄÎÊÌ⣬¸ßÊÖ½ø£¡
СµÜ×î½üÐèÒªÒ»¸öÓÃsocket»ñÈ¡htmlÎĵµµÄ´úÂ룬µ«ÊÇÀÏÊDz»ÄÜ»ñÈ¡ÍêÕûµÄhtmlÔ´Âë¡£ÔÒò²»Ã÷£¬Íû¸ßÊÖÖ¸µã£¡
C/C++ code:
char *Http_GET(char *host,int port,char *data) //·¢ËÍGETÇëÇó
{
char response[204800],http_request[2048],*ret; //½ÓÊÕÊý¾ÝµÄ»º³åÇø´óС200k ÇëÇóÄÚÈÝ»º³åÇø2k
struct hostent *get_ip_addr; //ÍøÂçµØÖ·µÄÊý¾Ý½á¹¹hostent
get_ip_addr = gethostbyname(host); //µ÷ÓÃgethostbyname»ñÈ¡Ö÷»úipµØÖ·£¬·ÅÈë½á¹¹Ìâget_ip_addr
struct sockaddr_in remote_host; //ÍøÂçsocket½á¹¹remote_host
remote_host.sin_family = AF_INET; //ʹÓÃTCP£¯IP
remote_host.sin_port = htons(port); //Ô¶³Ì¶Ë¿Ú
memcpy(&remote_host.sin_addr.s_addr,get_ip_addr->h_addr_list[0],sizeof(get_ip_addr->h_addr_list[0]));//»ñȡһ¸öIP°ÑËû·ÅÈëremote_host.sin_addr.s_addrµÄÄÚ´æ¿Õ¼ä
int remote_std = socket(AF_INET,SOCK_STREAM,0); //´ò¿ªsocket£¬²¢¶¨ÒåÌ×½Ó×Öremote_std
connect(remote_std,(struct sockaddr*)&remote_host,sizeof(remote_host)); //Á¬½ÓÄ¿±êÖ÷»ú
memset(http_request,'\0',sizeof(http_request)); //½«ÇëÇóÄÚÈݵÄÄÚ´æ¿Õ¼äÖÿÕ
// sprintf(http_request,get_format,data); //дÈëhttpÇëÇóÄÚÈÝ
strcpy(http_request,"GET /FT_class.php?t_type=h2&id=361\r\nHost: 60.248.11.100\r\nConnection: Close\r\n\r\n");
send(remote_std,http_request,strlen(http_request),0); //·¢ËÍÇëÇó
recv(remote_std,response,sizeof(response),0); //½ÓÊÕ·µ»Ø£
Ïà¹ØÎÊ´ð£º
C/C++ code:
char Time="2009-9-23";
FILE *fpOut=fopen("1.txt","w+");
if(fpOut==NULL)
return ;
fwr ......
¸ø¸öµØÖ·£¬»òÕß·¢µ½ÎÒÓÊÏäÒ²ÐÐ wrongagain98@163.com
×îºÃÊÇÊÓÆµµÄ£¬²»ÊÇÊÓÆµÆÕͨµÄÒ²ÐС£
Ö÷ÒªÊÇÁ½·½Ã棺
1.ÔõÑù±à¼¡¢±àÒëºÍµ÷ÊÔ³ÌÐò¡£Ï£ÍûÄÜÒ»²½²½½²Çå³þ£¬ÈçºÎ°²×°¡¢ÈçºÎÅäÖõȡ£²»Òª¾Íֻ˵¾ä¡°¾ÍÓ ......
ÎÒĿǰÔÚ±¾µØµÄlinuxÉÏдÁËÒ»¸öswingµÄ½çÃæ£¬Ïëͨ¹ýÕâ¸ö½çÃæÀ´¿ØÖÆÆäËüµçÄÔµÄlinuxÖØÆô¡£
ÎÒÖªµÀÓÃRuntime.getRuntime().exec("shutdown -r");¿ÉÒÔ¿ØÖƱ¾»úLinuxÖØÆô£¬µ«ÊÇÔõô¿ØÖÆÔ¶³ÌµÄlinuxÖØÆôÄØ£¿ ......
Õ¾µãÏÂÓÐ×ÓÎļþ¼Ð script Îļþ¼ÐÏÂÓÐjsÎļþindex.js
¸ùĿ¼ÏÂÓÐÎļþindex.php
ÏëȨÏÞÉèÖóÉÖ±½Óͨ¹ýURL:http://www.abc.com/script/index.jsÎÞ·¨·ÃÎÊ,ÐèҪȨÏÞ
µ«ÊÇͨ¹ýindex.phpµ ......