Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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); //½ÓÊÕ·µ»Ø£


Ïà¹ØÎÊ´ð£º

Ë­Äܸø¸öLinuxÏÂдC/C++³ÌÐòµÄ½Ì³Ì£¿

¸ø¸öµØÖ·£¬»òÕß·¢µ½ÎÒÓÊÏäÒ²ÐÐ wrongagain98@163.com
×îºÃÊÇÊÓÆµµÄ£¬²»ÊÇÊÓÆµÆÕͨµÄÒ²ÐС£

Ö÷ÒªÊÇÁ½·½Ã棺
1.ÔõÑù±à¼­¡¢±àÒëºÍµ÷ÊÔ³ÌÐò¡£Ï£ÍûÄÜÒ»²½²½½²Çå³þ£¬ÈçºÎ°²×°¡¢ÈçºÎÅäÖõȡ£²»Òª¾Íֻ˵¾ä¡°¾ÍÓ ......

linux»·¾³ÏÂgethostbynameº¯ÊýÎÊÌâ - C/C++ / CÓïÑÔ

дÁ˸ö²âÊÔ³ÌÐòÈçÏÂ
   
  struct hostent *hp; 
char AlarmDevIP[20];  
  int x2;

hp = gethostbyname("www.google.com");
if (hp)
{ ......

£ÛÇóÖú£ÝlinuxÍøÂç±à³ÌÖÐselect³ö´í

Ä¿±ê£ºµ±ÍøÂçÖÐÓÐÊý¾Ýµ½´ï»òÕß³¬Ê±£¬³ÌÐò½øÈëÏÂÒ»´ÎÑ­»·¡£
ÎÊÌ⣺select()º¯Êý²»Æð×÷Ó㬳ÌÐò²»»áÔÚselectµÄµØ·½×èÈûÒ»Ã룬²¢ÇÒµ±ÍøÂçÉÏÓÐÊý¾ÝµÄʱºò£¬selectµÄ·µ»ØÖµÈÔȻСÓÚ0
    #include <s ......

ǶÈëʽLinuxËõ¼õÎÊÌâ

´ó¼ÒºÃ£¬±¾ÈËĿǰ¸Õ¸Õ½Ó´¥Linux¡£ÏÖÔÚ¹«Ë¾µÄÏîÄ¿ÐèÒªËõ¼õLinuxµÄKernelºÍAPP²¿·ÖµÄCode Size¡£Ä¿Ç°ÎÒÃÇʹÓõÄÊÇLinux2.6.22.15°æ±¾£¬Ó¦ÓÃÓÚADSL Modem£¨¼ÒÍ¥Íø¹Ø£©¡£

1.ÎÒÃDzúÆ·Ó¦ÓÃÊÇADSL Gateway£¬Kernel²¿ ......

linux + oracleÓÃXP·ÃÎʲ»ÁË

ÎÒ°²×°Ò»Ì¨redhat linux5+oracle 10gµÄ·þÎñÆ÷£¬±Ê¼Ç±¾£¨XPϵͳ£©°²×°ÁËoracle 10g¿Í»§¶Ë,½á¹ûÀÏÊdzö12560µÄ´íÎó£¬Çë¸ßÊÖÖ¸µãÒ»¶þ£¬

-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dpor ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ