require "socket"
gs = TCPserver.open(0)
printf(“server is on port %d\n”, gs.addr[1])
s=gs.accept
puts s.gets
s.write(s.gets.upcase)
s.close
The preceeding code is used to run a server that accepts a
single client. The client sends the server a string, the
server reads and converts the string to uppercase and then
sends it back to the client.
That’s how it’s supposed to work and on the PC it does work.
However, on OpenVMS the client requires two, consecutive reads
in order to get the uppercased value from the server (i.e. first
read returns the original string “test”; second read returns the
modified string sent back by the server “TEST”). This leads me
to believe it’s an internal buffer problem. Before I speculate
further I wanted to ask if anyone has come across this before and
what may be the cause of it.
Change server.rb to only read from the client 1 time.
[jeremyhi@rapier ruby]$ cat server.rb
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 line
s.write(line.upcase)
s.close
The preceeding code is used to run a server that accepts a
single client. The client sends the server a string, the server
reads and converts the string to uppercase and then sends it
back to the client.
The server as originally written reads from the client twice, once for
each ‘gets’. Since the client is only writing once to the server this
is probably the underlying issue.
That’s how it’s supposed to work and on the PC it does work.
However, on OpenVMS the client requires two, consecutive reads
in order to get the uppercased value from the server (i.e. first
read returns the original string “test”; second read returns the
modified string sent back by the server “TEST”). This leads me
to believe it’s an internal buffer problem. Before I speculate
further I wanted to ask if anyone has come across this before
and what may be the cause of it.
Change server.rb to only read from the client 1 time.
[jeremyhi@rapier ruby]$ cat server.rb
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 line
s.write(line.upcase)
s.close
The preceeding code is used to run a server that accepts a
single client. The client sends the server a string, the server
reads and converts the string to uppercase and then sends it
back to the client.
The server as originally written reads from the client twice, once for
each ‘gets’. Since the client is only writing once to the server this
is probably the underlying issue.
That’s how it’s supposed to work and on the PC it does work.
However, on OpenVMS the client requires two, consecutive reads
in order to get the uppercased value from the server (i.e. first
read returns the original string “test”; second read returns the
modified string sent back by the server “TEST”). This leads me
to believe it’s an internal buffer problem. Before I speculate
further I wanted to ask if anyone has come across this before
and what may be the cause of it.
enjoy,
-jeremy
First, thanks for the speedy response!
Second, I modified the source per your suggestions, but without success.
This is now the code I’m running:
require “socket”
gs = TCPserver.open(0)
printf(“server is on port %d\n”, gs.addr[1])
s = gs.accept
line = s.gets
puts line
s.write(line.upcase)
s.flush
s.close
Perhaps something in the actual implimentation is the same
everywhere else except for OpenVMS. Hmm, wouldn’t be the first
time, but it is a pain.
I don’t have access to an OpenVMS machine myself so I’m just throwing
out ideas here.
Thanks for the reply! Unfortunately flushing the socket seems to have
had no effect. I think there is something internally, within the socket
implementation for OpenVMS, that is the problem. Something that I am
not yet familiar with. (like another post I made to the group regarding
threads: I had only to make an O/S specific define to make ruby threads
work on OpenVMS)
If I find the answer I’ll be sure to post it. And if you, or anyone
else has any further ideas I’m open to suggestions. I think I’ve
just about exhausted my resources. (But that doesn’t mean I’m giving
up.)
require “socket”
gs = TCPserver.open(0)
printf(“server is on port %d\n”, gs.addr[1])
s = gs.accept
line = s.gets
puts line
s.write(line.upcase)
s.flush
s.close
Perhaps something in the actual implimentation is the same
everywhere else except for OpenVMS. Hmm, wouldn’t be the first
time, but it is a pain.
I don’t have access to an OpenVMS machine myself so I’m just throwing
out ideas here.