I'm sorry this message is so long, but we are having some real trouble
using sockets from perl here, and I desperately want to get to the
bottom of it.  It appears that perl programs using sockets on our
OpenVMS system immediately echo back any messages they receive.

We have Perl 5.005_03 in production, but we have tested Perl 5.6.0 with
the same results.  We are using Multinet TCP/IP services on our system.
Build details are at the bottom of this message.

Here are some simple test programs that illustrate our problem:

#### start of fooserver.pl ####
#!/usr/bin/perl -w

use IO::Socket;
use strict;

my ($server, $server_port, $client, $send_string, $rec_string);
$rec_string = "";
$server_port = 0xf00;

$server = IO::Socket::INET->new(LocalPort => $server_port,
                                Type      => SOCK_STREAM,
                                Reuse     => 1,
                                Listen    => SOMAXCONN)
  or die "Couldn't be a tcp server on port $server_port : $@\n";

CONN: while ($client = $server->accept()) {
   print "Accepted connection from client\n";
   $send_string = "Initial hello from foo server\n";
   print "<< " . $send_string;
   print $client $send_string;
   while ($rec_string = <$client>) {
      print ">> " . $rec_string;
      if (uc($rec_string) =~ /^QUIT/) {
         print "... quitting ...\n";
         last CONN;
      }
      $send_string = "The foo server responds to the client.\n";
      print "<< " . $send_string;
      print $client $send_string;
   }
}
close($client);
#### end of fooserver.pl ####

and the client:
#### start of fooclient.pl ####
#!/usr/bin/perl -w

use IO::Socket;
use strict;

my ($conn, $send_string, $rec_string, $server_address, $server_port);
$server_address = $ARGV[0];
$server_port = 0xf00;

$conn = IO::Socket::INET->new(PeerAddr   => $server_address,
                                PeerPort => $server_port,
                                Proto    => "tcp",
                                Type     => SOCK_STREAM)
  or die "Couldn't connect: $@\n";

if (defined($rec_string = <$conn>)) {
   print ">> ". $rec_string;
}

$send_string = "This message is from the client\n";
print "<< " . $send_string;
print $conn $send_string;

if (defined($rec_string = <$conn>)) {
   print ">> ". $rec_string;
}

$send_string = "QUIT\n";
print "<< " . $send_string;
print $conn $send_string;

if (defined($rec_string = <$conn>)) {
   print ">> ". $rec_string;
}

close ($conn);
#### end of fooclient.pl ####
======================================================
The expected behavior is exhibited on linux:

(linux) server output:
bash$ ./fooserver.pl
Accepted connection from client
<< Initial hello from foo server
>> This message is from the client
<< The foo server responds to the client.
>> QUIT
... quitting ...

(linux) client output:
bash$ ./fooclient.pl localhost
>> Initial hello from foo server
<< This message is from the client
>> The foo server responds to the client.
<< QUIT
=======================================================
Now, with the server running on OpenVMS and the client running on linux:

(VMS) server output:
$ perl fooserver.pl
Accepted connection from client
<< Initial hello from foo server
>> This message is from the client
<< The foo server responds to the client.
>> QUIT
... quitting ...

(linux) client output:
bash$ ./fooclient.pl myvmsbox
>> Initial hello from foo server
<< This message is from the client
>> This message is from the client
<< QUIT
>> The foo server responds to the client.
=======================================================
Weird, huh?  Wait, it gets better ... here's the server on linux and
the client on OpenVMS:

(linux) server output:
bash$ ./fooserver.pl
Accepted connection from client
<< Initial hello from foo server
>> Initial hello from foo server
<< The foo server responds to the client.
>> This message is from the client
<< The foo server responds to the client.
>> The foo server responds to the client.
<< The foo server responds to the client.
>> QUIT
... quitting ...

(VMS) client output:
$ perl fooclient.pl mylinuxbox
>> Initial hello from foo server
<< This message is from the client
>> The foo server responds to the client.
<< QUIT
>> The foo server responds to the client.
=======================================================
Finally, both client and server on OpenVMS:

(VMS) server output:
$ perl fooserver.pl
Accepted connection from client
<< Initial hello from foo server
>> Initial hello from foo server
<< The foo server responds to the client.
>> Initial hello from foo server
<< The foo server responds to the client.

(VMS) client output:
$ perl fooclient.pl localhost
>> Initial hello from foo server
<< This message is from the client
>> Initial hello from foo server
<< QUIT
>> Initial hello from foo server
=======================================================
Note that, in this case, the server is still waiting for input.


Here's the build information:
$ perl "-V"
Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=VMS, osvers=V7.1-2, archname=VMS_AXP
    uname='VMS tybalt V7.1-2 AlphaServer 2000 5/300'
    config_args='-des'
    hint=none, useposix=false, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=undef 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='CC/DECC', optimize='', gccversion=undef
    cppflags='undef'
    ccflags ='/Include=[]/Standard=Relaxed_ANSI/Prefix=All/Obj=.obj/NoList'
    stdchar='char', d_stdstdio=define, usevfork=true
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=undef, Off_t='int', lseeksize=4
    alignbytes=8, usemymalloc=N, prototype=define
  Linker and Libraries:
    ld='Link', ldflags ='/NoTrace/NoMap'
    libpth=/sys$share /sys$library
    libs= 
    libc=(DECCRTL), so=exe, useshrplib=undef, libperl=undef
  Dynamic Linking:
    dlsrc=dl_vms.c, dlext=exe, d_dlsymun=undef, ccdlflags=''
    cccdlflags='', lddlflags='/Share'


Characteristics of this PERLSHR image: 
  Compile-time options: DEBUGGING
  Built under VMS
  Compiled at Oct 24 2000 11:09:49
  %ENV:
    PERLSHR="PERL_EXE:PERLSHR.EXE"
    PERL_EXE="PERL_ROOT:[000000]"
    PERL_ROOT="USER1:[PERL-5_6_0.]"
  @INC:
    perl_root:[lib.VMS_AXP.5_6_0]
    perl_root:[lib]
    perl_root:[lib.site_perl.VMS_AXP]
    perl_root:[lib.site_perl]
    /perl_root/lib/site_perl
    .
$ multinet show/version
Process Software MultiNet V4.3 Rev A-X, AlphaServer 2000 5/300, OpenVMS AXP V7.1-2

Any help getting things to work right would make me exceedingly happy!

-- 
| Forrest Cahoon      | [EMAIL PROTECTED] |------------------------------|
| 850 21st Ave SE     |----------------------| Only unbalanced people       |
| Mpls MN  55414-2514 |                      |        can tip the scales... |

Reply via email to