From: Axel Etzold Date: 2007-11-16T19:51:43+09:00 Subject: Questions about TCPSocket Dear all, I am trying to use Ruby bindings of a software that does computations by exchanging messages between competent code. The details are explained here: http://www.math.kobe-u.ac.jp/OpenXM/1.2.1/html/OpenXM-en/OpenXM/node5.html This software can be used from the command line and there, it works as expected. Now, I'd like to use it from ruby. There are ruby binding scripts. However, I encounter some problems when initialising TCPSocket - I can't get any connection. Both ruby and OpenXM are installed on the same computer. What could be the problem ? Thank you very much, Best regards, Axel require "socket" class OXSession def initialize(host = "localhost", controlport = rand(20000)+1024, dataport = controlport+1, byteorder = 0) @serial = 0 begin printf("Connecting to %s, \n", host) printf("Trying to connect to controlport %d, \n", controlport) @controlp = TCPSocket.new(host, controlport) sleep 2 printf("Trying to connect to dataport %d, \n", dataport) @datap = TCPSocket.new(host, dataport) sleep 2 rescue p 'could not connect' end # byte oder negotiation @byteorder = decide_byte_order(byteorder) end attr_accessor :controlp, :datap def decide_byte_order(b_or_l) if b_or_l == 0 @controlp.read(1) @datap.read(1) @controlp.flush @datap.flush @controlp.write(0) @datap.write(0) return 0 end end end -- GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS. Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail