NET :: presa :: nonBlocchi

Net :: presa :: NonBlock è un'estensione perl per una facile creazione applicazione a filettatura singola multi-socket.
Scarica ora

NET :: presa :: nonBlocchi Classifica e riepilogo

Annuncio pubblicitario

  • Rating:
  • Licenza:
  • Perl Artistic License
  • Prezzo:
  • FREE
  • Nome editore:
  • Daniel Podolsky
  • Sito web dell'editore:
  • http://search.cpan.org/~tpaba/Net-Socket-NonBlock-0.15/NonBlock.pm

NET :: presa :: nonBlocchi Tag


NET :: presa :: nonBlocchi Descrizione

Net :: Socket :: NONBLOCK è un'estensione Perl per applicazioni single-thread multi-presa facile creazione. Net :: Socket :: NONBLOCK è un'estensione Perl per applicazioni single-thread multi-presa facile creazione, in particolare non si biforcano porta TCP servers.SYNOPSIS # TCP spedizioniere con la registrazione # Funziona su Win32! usare rigoroso; uso Net :: Socket :: NONBLOCK; $ | ++; my $ PortaLocale = shift o morire "Utilizzo: $ 0 n"; my $ RemoteHost = shift o morire "Utilizzo: $ 0 n"; my $ SockNest = Net :: Socket :: :: NONBLOCK Nest-> nuovo (SelectT => 0.1, SilenceT => 0, debug => $ ^ W, BuffSize => 10240,) or die "Errore nella creazione prese nido: $ @n"; $ SockNest-> Listen (PortaLocale => $ PortaLocale, Proto => 'tcp', Accetta => NewConnection, SilenceT => 0, #ClientsST => 10, Listen => 10,) or die "Impossibile ascolto sulla porta ' $ PortaLocale ': $ @ n "; la mia% ConPool = (); while ($ SockNest-> IO ()) {my $ Pstr = ''; my $ ClnSock = undef; my $ SrvSock = undef; while (($ ClnSock, $ SrvSock) = each (% ConPool)) {my $ ClientID = sprintf ( ".15s:% - 5.5s", $ SockNest-> PeerAddr ($ ClnSock), $ SockNest-> PeerPort ( $ ClnSock)); my $ Str = undef; while (($ Str = $ SockNest-> Leggi ($ ClnSock)) Lunghezza ($ Str)) {$ Pstr = "$ ClientID dal client" .SafeStr ($ Str) "n"..; $ SrvSock-> puts ($ Str); }; if (defined ($ Str)!) {$ Pstr = "$ ClientID CLIENT closedn."; $ SockNest-> Chiudi ($ ClnSock); # Metodo vecchio stile chiamata $ SrvSock-> Close (); # Chiamata di metodo OO-style delete ($ ConPool {$ ClnSock}); prossimo; }; while (($ Str = $ SrvSock-> Read ()) Lunghezza ($ Str)) {$ Pstr = "$ ClientID dal server" .SafeStr ($ Str) "n"..; $ SockNest-> puts ($ ClnSock, $ Str); }; if (defined ($ Str)!) {$ Pstr = "$ ClientID SERVER closedn."; $ SockNest-> Chiudi ($ ClnSock); $ SrvSock-> Close (); delete ($ ConPool {$ ClnSock}); prossimo; }; }; if (length ($ Pstr)) {print localtime () "n" $ Pstr..; }; }; sub NewConnection {my ($ ClnSock) = shift o il ritorno; $ ConPool {$ ClnSock} = $ SockNest-> Connect (PeerAddr => $ RemoteHost, Proto => 'tcp',); if ($ ConPool {$ ClnSock}!) {warn "Impossibile connettersi a '$ RemoteHost': $ @ n"; $ ClnSock-> Close (); delete ($ ConPool {$ ClnSock}); Restituzione; }; ritorno 1; }; sub SafeStr {my $ Str = shift o il ritorno 'UNDEF!!'; $ Str = ~ s {()} {sprintf ( "\ x% 2.2X", ord ($ 1))} gsex; return $ Str; }; Requisiti: · Requisiti Perl: · Perl.


NET :: presa :: nonBlocchi Software correlato