11 if (!eval { require Socket }) {
12 plan skip_all => "no Socket";
14 elsif (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
15 plan skip_all => "EBCDIC but no Convert::EBCDIC";
20 use File::Temp 'tempfile';
23 my $debug = 0; # Net::NNTP->new( Debug => .. )
25 my $inet6class = Net::NNTP->can_inet6;
26 plan skip_all => "no IPv6 support found in Net::NNTP" if ! $inet6class;
28 plan skip_all => "fork not supported on this platform"
29 unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} ||
30 (($^O eq 'MSWin32' || $^O eq 'NetWare') and
31 $Config::Config{useithreads} and
32 $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/);
34 my $srv = $inet6class->new(
38 plan skip_all => "cannot create listener on ::1: $!" if ! $srv;
39 my $host = $srv->sockhost;
40 my $port = $srv->sockport;
41 note("server on $host port $port");
45 defined( my $pid = fork()) or die "fork failed: $!";
46 exit(nntp_server()) if ! $pid;
48 my $cl = Net::NNTP->new(Host => $host, Port => $port,, Debug => $debug);
49 note("created Net::NNTP object");
51 fail("IPv6 NNTP connect failed");
60 my $cl = $srv->accept or die "accept failed: $!";
61 print $cl "200 nntp.example.com\r\n";
63 my ($cmd,$arg) = m{^(\S+)(?: +(.*))?\r\n} or die $_;
65 if ($cmd eq 'QUIT' ) {
66 print $cl "205 bye\r\n";
68 } elsif ( $cmd eq 'MODE' ) {
69 print $cl "201 Posting denied\r\n";
71 diag("received unknown command: $cmd");
72 print "500 unknown cmd\r\n";
75 note("NNTP dialog done");