9 use File::Temp 'tempfile';
13 my $debug = 0; # Net::NNTP->new( Debug => .. )
15 my $inet6class = Net::NNTP->can_inet6;
16 plan skip_all => "no IPv6 support found in Net::NNTP" if ! $inet6class;
18 plan skip_all => "fork not supported on this platform"
19 unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} ||
20 (($^O eq 'MSWin32' || $^O eq 'NetWare') and
21 $Config::Config{useithreads} and
22 $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/);
24 my $srv = $inet6class->new(
28 plan skip_all => "cannot create listener on ::1: $!" if ! $srv;
29 my $host = $srv->sockhost;
30 my $port = $srv->sockport;
31 note("server on $host port $port");
35 defined( my $pid = fork()) or die "fork failed: $!";
36 exit(nntp_server()) if ! $pid;
38 my $cl = Net::NNTP->new(Host => $host, Port => $port,, Debug => $debug);
39 note("created Net::NNTP object");
41 fail("IPv6 NNTP connect failed");
50 my $cl = $srv->accept or die "accept failed: $!";
51 print $cl "200 nntp.example.com\r\n";
53 my ($cmd,$arg) = m{^(\S+)(?: +(.*))?\r\n} or die $_;
55 if ($cmd eq 'QUIT' ) {
56 print $cl "205 bye\r\n";
58 } elsif ( $cmd eq 'MODE' ) {
59 print $cl "201 Posting denied\r\n";
61 diag("received unknown command: $cmd");
62 print "500 unknown cmd\r\n";
65 note("NNTP dialog done");