On Fri, 5 Nov 2004, Ben Armstrong wrote:

> Hi,
>
> We're having problems with the standard Socket module with Ruby.  It has
> been alleged that this might be a C Runtime issue.  But this seems
> unlikely in light of the fact that other ports on the same platform --
> notably Perl, and perhaps also Python -- have working sockets, also
> implemented on top of the same C Runtime.

i'm guessing you are using 'print' in the perl version and, therefore, not
sending a bunch of extra newlines as the code below is doing do to 'puts'?
not sure why that'd make a difference but...

-a

>
> Can someone shed some light on what may be going on?
>
> Here is a failing case, as we first reported the problem:
>
> client.rb:
>        require 'socket'
>        s=TCPSocket.new("localhost", ARGV[0])
>        s.puts("test\r\n")
>        puts s.gets
>        s.puts("Blah, blah\r\n")
>        puts s.gets
>        s.close
>
> server.rb:
>        require 'socket'
>        gs = TCPServer.open(0)
>        printf("server is on port %d\n", gs.addr[1])
>        s=gs.accept
>        line = s.gets
>        puts("Got line: #{line}")
>        s.puts(line.upcase)
>        bl = s.gets
>        puts ("Got str2: #{bl}")
>        s.puts(bl.upcase)
>        s.close
>
> On Linux (ruby 1.8.2), this gave the following output, as expected:
>     (client side)
>        TEST
>        BLAH, BLAH
>     (server side)
>        server is on port 40050
>        Got line: test
>        Got str2: Blah, blah
>
> On OpenVMS (ruby 1.8.1), this surprisingly gave the following output:
>     (client side)
>        test
>        test
>     (server side)
>        server is on port 49379
>        Got line: test
>        Got str2: test
>
> We tried varying the test by changing our puts to write on the client
> side, but the test results were the same on both platforms.
>
> Thanks,
> Ben Armstrong
> --
>      Ben Armstrong                -.       Medianet Development Group,
>      BArmstrong / dymaxion.ca         `-.    Dymaxion Research Limited
>      <URL: http://www.dymaxion.ca/>    `-  Halifax, Nova Scotia, Canada
>
>

-a
--
===============================================================================
| EMAIL   :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE   :: 303.497.6469
| When you do something, you should burn yourself completely, like a good
| bonfire, leaving no trace of yourself.  --Shunryu Suzuki
===============================================================================