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

»ùÓÚLinuxµÄSocketÍøÂç±à³ÌµÄÐÔÄÜÓÅ»¯

»ùÓÚLinuxµÄSocketÍøÂç±à³ÌµÄÐÔÄÜÓÅ»¯
2009-10-23      ǶÈëʽÔÚÏß      ÊÕ²Ø | ´òÓ¡
1 ÒýÑÔ
    Ëæ×ÅIntenetµÄÈÕÒæ·¢Õ¹ºÍÆÕ¼°£¬ÍøÂçÔÚǶÈëʽϵͳÖÐÓ¦Ó÷dz£¹ã·º£¬Ô½À´Ô½¶àµÄǶÈëʽÉ豸²ÉÓÃLinux²Ù×÷ϵͳ¡£LinuxÊÇÒ»¸öÔ´´úÂ빫¿ªµÄÃâ·Ñ²Ù×÷ϵͳ£¬¾ßÓÐÇ¿ÒÆÖ²ÐÔ£¬ËùÒÔ¶Ô»ùÓÚLinuxµÄSocketÍøÂç±à³ÌµÄÑо¿Ô½À´Ô½ÖØÒª¡£
    Socketʵ¼ÊÊÇÍøÂç´«Êä²ã¹©¸øÓ¦ÓòãµÄ±à³Ì½Ó¿Ú¡£´«Êä²ãÔòÔÚÍøÂç²ãµÄ»ù´¡ÉÏÌṩ½ø³Ìµ½½ø³ÌÎʵÄÂß¼­Í¨µÀ£¬¶øÓ¦ÓòãµÄ½ø³ÌÔòÀûÓô«Êä²ãÏòÁíһ̨Ö÷»úµÄijһ½ø³ÌͨÐÅ¡£Socket¾ÍÊÇÓ¦ÓòãÓë´«Êä²ãÖ®¼äµÄÇÅÁº¡£Èçͼ2Ëùʾ¡£
    ʹÓÃSocket±à³Ìʱ¿ÉÒÔ¿ª·¢¿Í»§»úºÍ·þÎñÆ÷Ó¦ÓóÌÐò£¬ËüÃÇ¿ÉÒÔÔÚ±¾µØÍøÂçÉϽøÐÐͨÐÅ£¬Ò²¿ÉÒÔͨ¹ýInternetÔÚÈ«Çò·¶Î§ÄÚ½øÐÐͨÐÅ¡£±àд²¢ÔËÐÐ SocketµÄ¿Í»§¶ËºÍ·þÎñÆ÷¶Ë³ÌÐò£¬Ë«·½Í¨¹ýÌ×½Ó×Ö½¨Á¢ÁË·þÎñÁ¬½ÓÇëÇ󣬲¢ÇÒͨ¹ýһЩ·½·¨Ìá¸ßSocketµÄÐÔÄÜ¡£
3 Socket±à³Ì
3£®1 SocketÀàÐÍ
    ³£¼ûµÄSocketÓÐ3ÖÖÀàÐÍ£º
    (1)Á÷ʽSocket(SOCK_STREAM)ËüÌṩ¿É¿¿µÄͨÐÅÁ÷£¬Ê¹ÓÃÃæÏòÁ¬½ÓµÄTCPЭÒ飬´Ó¶ø±£Ö¤Êý¾Ý´«ÊäµÄÕýÈ·ÐÔºÍ˳ÐòÐÔ£º
    (2)Êý¾Ý±¨Socket(SOCK_DGRAM)Êý¾Ýͨ¹ýÏ໥¶ÀÁ¢µÄ±¨ÎĽøÐд«Ê䣬ÊÇÎÞÐòµÄ£¬²¢ÇÒ²»±£Ö¤¿É¿¿£¬ÎÞ²î´í£¬Ëü¶¨ÒåÒ»ÖÖÃæÏòÎÞÁ¬½ÓµÄ·þÎñ£¬Ê¹ÓÃÊý¾Ý±¨Ð­ÒéUDP£»
    (3)ԭʼSocket(SOCK_RAM)ËüÔÊÐíÖ±½Ó·ÃÎʵײãЭÒ飬¹¦ÄÜÇ¿´óµ«Ê¹ÓýÏΪ²»±ã£¬Ö÷ÒªÓÃÓÚһЩЭÒéµÄ¿ª·¢¡£±¾±àдµÄSocketÊôÓÚÁ÷ʽSocket¡£
3£®2 Socket±à³ÌÁ÷³Ì
    Socket±à³Ì²ÉÓÿͻ§£¯·þÎñÆ÷ģʽ¡£Òò´Ë±à³Ì·ÖΪ·þÎñÆ÷¶ËºÍ¿Í»§¶ËÁ½²¿·Ö¡£
    ÿһ¸öSocket¶¼ÓÃÒ»¸ö°ëÏà¹ØÃèÊö(ЭÒ飬±¾µØµØÖ·£¬±¾µØ¶Ë¿Ú)À´±íʾ£¬SocketÒ²ÓÐÒ»¸öÀàËÆÓÚÎļþ´ò¿ªµÄº¯Êý£¬¸Ãº¯Êý·µ»ØÒ»¸öÕûÐ͵ÄSocketÃèÊö·û£¬Ëæºó½¨Á¢Á¬½Ó£¬Êý¾Ý´«ÊäµÈ²Ù×÷¶¼Í¨¹ýSocketÀ´ÊµÏÖ¡£
    ±à³ÌÁ÷³ÌÈçÏ£º·þÎñÆ÷¶ËÊ×ÏȽ¨Á¢Socket£¬·µ»Ø¸ÃSocketµÄÃèÊö·û£ºÅäÖÃSocketµÄ¶Ë¿ÚºÍIPµØÖ·£»½¨Á¢¼àÌýð®Êý£¬¼ì²âÊÇ·ñÓпͻ§¶ËÏò·þÎñÆ÷·¢ËÍÇëÇó£¬ÈôÓÐÔò½ÓÊÕ¸ÃÇëÇ󣬽«Æä·Åµ½½ÓÊÕ¶ÓÁÐÖУº´Ó½ÓÊÕ¶ÓÁÐÖнÓÊÜÒ»¸öÇëÇó£»²¢Ïò¿Í»§¶Ë·¢ËÍÈ·ÈÏÁ¬½ÓÐÅÏ¢¡£
    ¿Í»§¶Ë½¨Á¢Ò»¸öSocket£¬·µ»Ø¸ÃSocketµÄÃèÊö·û£»ÅäÖÃSocket¶Ë¿ÚºÍIPµØÖ·£»Ïò·þÎñÆ÷·¢ËÍÁ¬½ÓÇëÇ󣬲¢½ÓÊÕ·þ


Ïà¹ØÎĵµ£º

Linux ÖÐÈçºÎ²éѯºÍжÔØÒÑ°²×°µÄÈí¼þ

Linux ÖÐÈçºÎ²éѯºÍжÔØÒÑ°²×°µÄÈí¼þ
¡¡¡¡LinuxÈí¼þµÄ°²×°ºÍжÔØÒ»Ö±ÊÇÀ§ÈÅÐí¶àÐÂÓû§µÄÄÑÌâ¡£ÔÚWindowsÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÈí¼þ×Ô´øµÄ°²×°Ð¶ÔسÌÐò»òÔÚ¿ØÖÆÃæ°åÖеēÌí¼Ó/ɾ³ý³ÌÐò” À´ÊµÏÖ¡£ÓëÆäÏàÀàËÆ£¬ÔÚLinuxÏÂÓÐÒ»¸ö¹¦ÄÜÇ¿´óµÄÈí¼þ°²×°Ð¶Ôع¤¾ß£¬ÃûΪRPM¡£Ëü¿ÉÒÔÓÃÀ´½¨Á¢¡¢°²×°¡¢²éѯ¡¢¸üС¢Ð¶ÔØÈí¼þ¡£¸Ã¹¤ ......

LinuxÖеĵØÖ·¿Õ¼ä

LinuxÖеĵØÖ·¿Õ¼ä
ÓÐÕâôһϵÁеÄÎÊÌ⣬ÊÇ·ñÔÚÀ§ÈÅ×ÅÄ㣺Óû§³ÌÐò±àÒëÁ¬½ÓÐγɵĵØÖ·¿Õ¼äÔÚʲô·¶Î§ÄÚ£¿Äں˱àÒëºóµØÖ·¿Õ¼äÔÚʲô·¶Î§ÄÚ£¿Òª¶ÔÍâÉè½øÐзÃÎÊ£¬I/OµÄµØÖ·¿Õ¼äÓÖÊÇʲôÑùµÄ£¿
ÏȻشðµÚÒ»¸öÎÊÌâ¡£Linux×î³£¼ûµÄ¿ÉÖ´ÐÐÎļþ¸ñʽΪelf(Executable and Linkable Format)¡£ÔÚelf¸ñʽµÄ¿ÉÖ´ÐдúÂëÖУ¬ld×ÜÊÇ´Ó0x ......

LinuxÏÂscpµÄÓ÷¨


scp¾ÍÊÇsecure copy£¬Ò»¸öÔÚlinuxÏÂÓÃÀ´½øÐÐÔ¶³Ì¿½±´ÎļþµÄÃüÁî¡£
ÓÐʱÎÒÃÇÐèÒª»ñµÃÔ¶³Ì·þÎñÆ÷ÉϵÄij¸öÎļþ£¬¸Ã·þÎñÆ÷¼ÈûÓÐÅäÖÃftp·þÎñÆ÷£¬Ò²Ã»ÓÐ×ö¹²Ïí£¬ÎÞ·¨Í¨¹ý³£¹æ;¾¶»ñµÃÎļþʱ£¬Ö»ÐèҪͨ¹ý¼òµ¥µÄscpÃüÁî±ã¿É´ïµ½Ä¿µÄ¡£
Ò»¡¢½«±¾»úÎļþ¸´ÖƵ½Ô¶³Ì·þÎñÆ÷ÉÏ
#scp /home/administrator/news.txt root@192.168.6.12 ......

linuxÖеÄÓ²Á´½ÓºÍ·ûºÅÁ´½Ó

Ë÷Òý½Úµã¡¢Ó²Á¬½ÓºÍÁ¬½Ó¼ÆÊý
Ë÷Òý½Úµãinode£º
    LinuxΪÿ¸öÎļþ·ÖÅäÒ»¸ö³ÆΪË÷Òý½ÚµãµÄºÅÂëinode£¬¿ÉÒÔ½«inode¼òµ¥Àí½â³ÉÒ»¸öÖ¸Õ룬ËüÓÀÔ¶Ö¸Ïò±¾ÎļþµÄ¾ßÌå´æ´¢Î»Öá£ÏµÍ³ÊÇͨ¹ýË÷Òý½Úµã(¶ø²»ÊÇÎļþÃû)À´¶¨Î»Ã¿Ò»¸öÎļþ¡£
    ÀýÈ磺¼ÙÉèÎÒÃÇÔÚÓ²Å̵±Ç°Ä¿Â¼Ï½¨Á¢ÁËÒ»¸öÃûΪmytextÎı ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ