| net :: socket :: nonblock. NET :: SOCKET :: NONBLOCKÀº ½¬¿î »ý¼º ¸ÖƼ ¼ÒÄÏ ½Ì±Û ½º·¹µå ÀÀ¿ë ÇÁ·Î±×·¥À»À§ÇÑ PERL È®ÀåÀÚÀÔ´Ï´Ù. |
Áö±Ý ´Ù¿î·Îµå |
net :: socket :: nonblock. ¼øÀ§ ¹× ¿ä¾à
- ƯÇã:
- Perl Artistic License
- °Ô½ÃÀÚ À̸§:
- Daniel Podolsky
- °Ô½ÃÀÚ À¥»çÀÌÆ®:
- http://search.cpan.org/~tpaba/Net-Socket-NonBlock-0.15/NonBlock.pm
net :: socket :: nonblock. ű×
net :: socket :: nonblock. ¼³¸í
net :: socket :: nonblockÀº ½¬¿î »ý¼º ¸ÖƼ ¼ÒÄÏ ½Ì±Û ½º·¹µå ÀÀ¿ë ÇÁ·Î±×·¥À»À§ÇÑ Perl È®ÀåÀÚÀÔ´Ï´Ù. net :: socket :: nonblockÀº ½¬¿î ÀÛ¼º ¸ÖƼ ¼ÒÄÏ ½Ì±Û ½º·¹µå ÀÀ¿ë ÇÁ·Î±×·¥, ƯÈ÷ Æ÷Å©°¡¾ø´Â TCP Servers.Synopsis # TCP Æ÷Æ® Àü´ÞÀÚ°¡ Win32¿¡¼ ÀÛµ¿ÇÕ´Ï´Ù! ¾ö°ÝÇÑ »ç¿ë; net :: socket :: nonblock; $ | ++; MY $ localport = Shift ¶Ç´Â DIE "»ç¿ë : $ 0 n"; MY $ REMOTEHOST = SHIFT ¶Ç´Â DIE "»ç¿ë : $ 0 N"; MY $ SOCKNEST = NET :: SOCKET-> NONBLOCK :: NEST-> NEW (select => 0.1, silencet => 0, debug => $ ^ w, buffsize => 10240) ¶Ç´Â ´ÙÀÌ "¼ÒÄÏ µÕÁö¸¦ ¸¸µå´Â ¿À·ù : $ @N"; $ socknest-> listen (localport => $ localport, proto => 'tcp', accept => newconnection, silencet => 0, #clientsst => 10, listen => 10) ¶Ç´Â Á×À» ¼ö ¾ø½À´Ï´Ù " $ localport ': $ @ n "; ³» % conpool = (); while ($ socknest-> io ()) {my $ pstr = ''; ³» $ clnsock = undef; ³» $ srvsock = undef; while (($ clnsock, $ srvsock) = °¢ (% conpool)) {my $ clientId = sprintf ( ".15s : % - 5.5s", $ socknest-> peeraddr ($ clnsock), $ socknest-> peerport ( $ clnsock)); ³» $ str = undef; while ($ str = $ socknest-> Àбâ ($ str)) {$ PSTR. = "Ŭ¶óÀ̾ðÆ®¿¡¼ $ CLIENID".SAFERST ($ str). "n"; $ srvsock-> puts ($ str); }; if (! Á¤ÀÇ ($ str)) {$ PSTR. = "$ CLIENID Ŭ¶óÀ̾ðÆ® CRECINGN"; $ socknest-> ´Ý±â ($ clnsock); # ÀÌÀü ½ºÅ¸ÀÏ ¸Þ¼Òµå $ srvsock-> close (); # oo-style ¸Þ¼Òµå È£Ãâ »èÁ¦ ($ conpool {$ clnsock}); ´ÙÀ½; }; while (($ str = $ srvsock-> read ()) ±æÀÌ ($ str) {$ PSTR. = "server¿¡¼ $ clientId".SafeRStr ($ str) "n"; $ socknest-> puts ($ clnsock, $ str); }; if (pedmed ($ str)) {$ PSTR. = "$ CLIENID SERVER CRIENTN"; $ socknest-> ´Ý±â ($ clnsock); $ srvsock-> close (); »èÁ¦ ($ conpool {$ clnsock}); ´ÙÀ½; }; }; if (length ($ PSTR)) {localtime () "n". $ pstr; }; }; Sub NewConnection {My ($ clnsock) = À̵¿ ¶Ç´Â ¹Ýȯ; $ conpool {$ clnsock} = $ socknest-> connect (peeraddr => $ remotehost, proto => 'tcp'); if (! $ conpool {$ clnsock}) {$ REMOTEHOST '¿¡ ¿¬°áÇÒ ¼ö ¾ø½À´Ï´Ù : $ @ n "; $ clnsock-> close (); »èÁ¦ ($ conpool {$ clnsock}); ¹ÝÇ°; }; ¹Ýȯ 1; }; Sub SafestR {My $ str = Shiping ¶Ç´Â Return '! Undef!'; $ str = ~ s {()} {sprintf ( "\ x % 2.2x", Ord ($ 1))} gsex; ¹Ýȯ $ str; }; ¿ä±¸ »çÇ× : ¡¤ Perl ¿ä±¸ »çÇ× : ¡¤ Perl.
net :: socket :: nonblock. °ü·Ã ¼ÒÇÁÆ®¿þ¾î