📂 Advanced File Manager
Multi-Root Navigation System
⚡ Quick Jump
Server (/)
Home (/home)
Var_www (/var/www)
Current (/home4/shelley/public_html/shelleycutler.com/wp-content/mu-plugins)
📍 Go
⬆ Ke Atas
🏠 Root Server
🏠 Root App
🔄 Refresh
📀 /
›
usr
›
share
›
doc
›
perl-IO-Socket-IP
›
📁 examples
📍
Lokasi:
/usr/share/doc/perl-IO-Socket-IP/examples
💾
Free:
45.8 GB
⚠️ Direktori ini
tidak writable
.
✏️ Mengedit: nonblocking_libasyncns.pl
#!/usr/bin/perl use strict; use warnings; use Errno qw( EINPROGRESS ); use IO::Poll; use IO::Socket::IP; use Net::LibAsyncNS; use Socket qw( SOCK_STREAM ); my $host = shift @ARGV or die "Need HOST\n"; my $service = shift @ARGV or die "Need SERVICE\n"; my $poll = IO::Poll->new; my $asyncns = Net::LibAsyncNS->new( 1 ); my $asyncns_fh = $asyncns->new_handle_for_fd; my $q = $asyncns->getaddrinfo( $host, $service, { socktype => SOCK_STREAM } ); $poll->mask( $asyncns_fh => POLLIN ); while( !$q->isdone ) { $poll->poll( undef ); if( $poll->events( $asyncns_fh ) ) { $asyncns->wait( 0 ); } } $poll->mask( $asyncns_fh => 0 ); my ( $err, @peeraddrinfo ) = $asyncns->getaddrinfo_done( $q ); $err and die "getaddrinfo() - $!"; my $socket = IO::Socket::IP->new( PeerAddrInfo => \@peeraddrinfo, Blocking => 0, ) or die "Cannot construct socket - $@"; $poll->mask( $socket => POLLOUT ); while(1) { $poll->poll( undef ); if( $poll->events( $socket ) & POLLOUT ) { last if $socket->connect; die "Cannot connect - $!" unless $! == EINPROGRESS; } } printf STDERR "Connected to %s:%s\n", $socket->peerhost_service; $poll->mask( \*STDIN => POLLIN ); $poll->mask( $socket => POLLIN ); while(1) { $poll->poll( undef ); if( $poll->events( \*STDIN ) ) { my $ret = STDIN->sysread( my $buffer, 8192 ); defined $ret or die "Cannot read STDIN - $!\n"; $ret or last; $socket->syswrite( $buffer ); } if( $poll->events( $socket ) ) { my $ret = $socket->sysread( my $buffer, 8192 ); defined $ret or die "Cannot read socket - $!\n"; $ret or last; STDOUT->syswrite( $buffer ); } }
💾 Simpan Perubahan
❌ Batal
📤 Upload
📁 Buat Folder
Nama
Ukuran
Dimodifikasi
Permission
Aksi
📎
connect.pl
1.1 KB
2020-09-15 16:05
0644
✏️ Edit
⬇
✍️
🗑️
📎
nonblocking_libasyncns.pl
1.6 KB
2020-09-15 16:05
0644
✏️ Edit
⬇
✍️
🗑️
✍️ Rename:
Nama Baru:
Batal
💾 Simpan