Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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µÄÐÐΪ

• ʵÑéÄ¿µÄ
      ͨ¹ý±¾ÊµÑ飬Á˽âLinuxϵͳµÄ×éÖ¯ºÍÐÐΪ£¬¹Û²ì¸÷Öִ洢ϵͳ״̬ÐÅÏ¢µÄÄں˱äÁ¿£»ÊìϤÕâЩ½á¹¹ÓëÐÅÏ¢¡£
• ʵÑéÄÚÈÝ
      ±àд³ÌÐò´òÓ¡³öÈç ......

linux °²×°xinetdµÄÎÊÌâ

ÒòΪ°²×°cvsÒªÓõ½xinetd·þÎñ£¬·¢ÏÖ»úÆ÷ÉÏûÓС£¡£¾Í´ÓÍøÉÏÏÂÔØÁ˸ö×°ÉÏ£¬
SQL code:
[root@localhost ~]# rpm -qa xinetd
[root@localhost ~]# rpm -qa telnet
telnet-0.17-38.el5
[root@localhost ~]#
¸ ......

ÇëÎÊÓÐûÓÐÈ«ÖÐÎĵÄlinuxϵͳ£¿

ÎÒÓùýubuntu8.10°æ±¾£¬´ÓverycdÏÂÔصġ£

ÏÂÔغó£¬ÊÇ°ëÓ¢ÎÄ¡£ÇÒÎÒ¶ÔlinuxϵͳµÄ²Ù×÷Àí½â²»ÉÒò´Ë×°ÖÐÎÄÊäÈë·¨¶¼¸ãÁ˺þá£

È»ºó°´ÕÕÍøÉϵĽ̸̳üÐÂÖÐÎĽçÃ棬µ«ÊǸüÐÂÁË1ÍíÉϺóÌáʾÖжϡ­¡­Àס£
......

¹ØÓÚLinuxϵͳµÄ-dfÖ¸Áî

ÓÃ-dfÖ¸Áîºó²éѯ³öÈçϽá¹û
/dev/hda2 1361587 1246406 44823 97£¥ / 
ÇëÎÊ£¬×îºóµÄ°Ù·Ö±ÈÖµÓ¦¸ÃÔÚ¶àÉÙ·¶Î§ÄÚ²ÅËãÕý³££¿
ÕâûÓÐÕý³£²»Õý³£Ò»Ëµ, ÏÔʾµÄÊÇÄãÓ²Å̵ÄʹÓÃÇé¿ö.
ÄãµÄ¸ù·ÖÇøÒѾ­Ê¹ÓÃÁË97% ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ