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

linux pipe() ÍÁÎÊ

ÍøÉÏ¿´ÁËһϣ¬´ó²¿·ÖµÄpipe()¶¼ÊǺÍfork£¨£©Í¬Ê±³öÏÖµÄ
ÏëÎÊÎʸßÊÖ£¬ÓÐûÓÐʲô·½·¨¿ÉÒÔ²»ÓÃpipe()+fork()
¶øÓÃpipe() read() write() dup2() system ()ʵÏÖpopen() µÄ¹¦ÄÜ
Èç¹ûÓиßÊÖÄܸ½ÉÏ´úÂë½²½âµÄ»°~~»á¸ø¼Ó·Ö~~~
×øµÈ±¯¾ç¡£

¸ÒÎÊÄãÊÇÏëʵÏÖʲô¹¦ÄÜÄØ£¿
ÊǹØÓÚIPCµÄ¹¦ÄÜÂð£¿
Èç¹ûÊǵĻ°£¬Ã²ËÆû·¨ÊµÏÖ£¬ÎҼǵá¶unixÍøÂç±à³Ì¡·Ìáµ½¹ý£¬½ø³Ì¼äͨѶÈç¹ûÏëʹÓÃpipe½øÐУ¬Ôò±ØÐëÊǸ¸×Ó½ø³Ì

system Ö®ºó¸¸½ø³ÌÒѾ­¿ªÊ¼ËÀµÈÁË£¬ÔõôͨÐÅ£¿
system = fork + exec + wait

pipe() read() write() dup2() system ()ʵÏÖpopen()
×öÃΰÉ

±ÈÈç˵£ºÎÒÏëÓÃsystem()µ÷ÓÃÒ»¸öshell ÃüÁî£à£à£à±ÈÈç˵cal  system("cal") ÎÒÏëÏÈÓÃÒ»¸ö int pdfs[2] µ±¹ÜµÀ£¬È»ºóµ÷ÓÃdup2£¨pdfs[1],1)ÕâÑù¾Í¿ÉÒÔ½«system("cal")Êä³öµÄ¹ÜµÀµÄдÈë¶Ë£¬È»ºóÔÙÔÚÁíÍâÒ»¸öº¯ÊýÖÐͬÑùµ÷Óà readº¯ÊýÀ´¶Ápdfs[0]ÖеÄÄÚÈÝ£¬È»ºó½øÐд¦Àí£à£à£àµ«ÊÇÿ´Î³ÌÐò×ßµ½dup2(pdfs[1],1)µÄʱºò¾Í±¨¸æ˵ÊÇbroken pipe````ÎҾͺܲ»Ã÷°×£à£à£à£à¸Ð¾õÓ¦¸ÃûÎÊÌâ°¢£à£à£à£à


Ïà¹ØÎÊ´ð£º

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

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

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

Linux Socket HTTPÇëÇóµÄÎÊÌ⣬¸ßÊÖ½ø£¡

СµÜ×î½üÐèÒªÒ»¸öÓÃsocket»ñÈ¡htmlÎĵµµÄ´úÂ룬µ«ÊÇÀÏÊDz»ÄÜ»ñÈ¡ÍêÕûµÄhtmlÔ´Âë¡£Ô­Òò²»Ã÷£¬Íû¸ßÊÖÖ¸µã£¡
C/C++ code:

char *Http_GET(char *host,int port,char *data) //·¢ËÍGETÇëÇó
{
char response[2 ......

LinuxÏ°²×°ÎÊÌâ

Ô­ÏȵÄGCC°æ±¾Îª4.1.2,ÎÒÖØбàÒë°²×°ÁËGCC4.3.2£¬µ«ÊDZàÒëÍê³ÌÐòÔËÐгÌÐòʱ»á³öÏÖversion `GLIBCXX_3.4.9' not found Õâ¸öÎÊÌ⣬ÎÒ²»Ì«Ã÷°×Ôõô»ØÊ£¬Çë¸÷λ´óϺָµãһϡ£
ÊÖ¶¯ÔÙ×°Ò»´Îglibc*_3.4.9

ÕâÊÇÎ ......

Linux ½ø³ÌÎÊÌâ

linux Ͻø³Ì´´½¨¡£
ʹÓÃvfork() º¯Êý´´½¨ÁË×Ó½ø³Ìºó£¬×Ó½ø³ÌÏÈÐÐÖ´ÐУ¬ÔÚ×Ó½ø³Ìµ÷ÓÃexit»òexec֮ǰ¸¸½ø³Ì´¦ÓÚʲô״̬£¿£¿
²»ÖªµÀ£»Ê×ÏÈδ±ØÊÇ×Ó½ø³ÌÏÈÖ´ÐУ»µÚ2¸¸½ø³ÌÒ²´¦ÓÚÖ´ÐÐ״̬£»ÖÁÓÚ¸¸½ø³Ìµ½µ××öʲô£»¿´´ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ