I have been desperately trying to convert the following perl programme
to Ruby. What should I use for the functions sockaddr_in (maybe the
famous pack(“snCaaaa8”) ?) and syswrite.
Thank for assisting me!
Johannes
Here’s the perl programme I have been trying to convert to Ruby
if (!(defined $ServerPort) || !(connect(SOCK,$paddr))) {
print “Error: could not open socket to Visual.\n”;
print “Probably because Visual either crashed or was killed.\n”;
exit 0;
}
I have been desperately trying to convert the following perl programme
to Ruby. What should I use for the functions sockaddr_in (maybe the
famous pack("snCaaaa8") ?) and syswrite.
I also tried recvfrom instead of gets, no matter how, each time the
connection gets reset.
The I replaced ‘localhost’ with the servers actual IP address, getting
the same result.
The perl programme always gets a correct answer from the server.
Johannes
ts wrote:
···
I have been desperately trying to convert the following perl programme
to Ruby. What should I use for the functions sockaddr_in (maybe the
famous pack(“snCaaaa8”) ?) and syswrite.
well, the difference with the perl program is perhaps here
select(SOCK);
$|=1;
select(STDOUT);
it force a flush after every print, try to add
t.sync = true
svg% ri IO#sync=
--------------------------------------------------------------- IO#sync=
ios.sync = aBoolean -> aBoolean
···
------------------------------------------------------------------------
Sets the ``sync mode'' to true or false. When sync mode is true,
all output is immediately flushed to the underlying operating
system and is not buffered internally. Returns the new state.
f = File.new("testfile")
f.sync = true
did you considred that ‘puts’ adds a line separatore by itself ?
You should be using print or set the default line saparetor to \r\n
#puts add a line separator if it don’t exist :
svg% ruby -e ‘puts “a”; puts “b\n”; puts “c\n\n”’
a
b
c
svg%
Guy Decoux
Thanks and sorry for not returning immediately.
I replaced puts with print and that clumsy string (#S(netutl…)) I
have to send to the server. Unfortunately I got the same results
(Connection reset by peer).