From: Johannes Steigerwald Date: 2003-09-29T21:35:03+09:00 Subject: Re: Ruby Newbie's Question: Sockets - searching for equivalent to a perl programme Thanks Guy, now, while the perl programme works perfectly fine, I have difficulties with the TCPSocket version. I tried: irb(main):029:0* t=TCPSocket.new('localhost',8530) # irb(main):030:0> t.addr ["AF_INET", 61501, "127.0.0.1", "127.0.0.1"] irb(main):031:0> t.peeraddr ["AF_INET", 8530, "127.0.0.1", "127.0.0.1"] irb(main):032:0> t.puts("#$(netutl-client-msg-header netutl-client-msg-type/gui-blocking \"Perl client\")\r\n") nil irb(main):033:0> t.puts("(ivel-window-get-active-vref)\r\n") nil irb(main):034:0> t.gets Errno::ECONNRESET: Connection reset by peer from (irb):34:in `gets' from (irb):34 irb(main):035:0> 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: > > >>>>> "J" == Johannes Steigerwald writes: > > J> I have been desperately trying to convert the following perl programme > J> to Ruby. What should I use for the functions sockaddr_in (maybe the > J> famous pack("snCaaaa8") ?) and syswrite. > > Well, look at the class TCPSocket > > http://www.rubycentral.com/book/lib_network.html#TCPSocket.new > > http://www.ruby-lang.org/en/man-1.4/socket.html#TCPSocket > > Guy Decoux -- ------------------------------------------------------------------- |Johannes Steigerwald | Oc� Printing Systems GmbH, TEC35| |phone: +49-8121-72-4912 | Siemensallee 2 | |fax: +49-8121-72-3173 | D-85586 Poing - Germany | |johannes.steigerwald@ops.de | www.oce.com | -------------------------------------------------------------------