From: bussiere bussiere Date: 2010-05-07T05:45:57+09:00 Subject: Re: gserver problem --0016363b9bce5d3e610485f307b5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable it works thanks a lot Bussiere 2010/5/6 Jes=FAs Gabriel y Gal=E1n > On Thu, May 6, 2010 at 10:26 PM, bussiere bussiere > wrote: > > hi, i am a beginner in ruby and > > i've made to tiny scripts but it doesn't seem to work if you have any > idea > > thanks : > > server : > > require 'gserver' > > > > class BasicServer < GServer > > def serve(io) > > loop do > > line =3D "" > > line =3D io.gets > > puts line > > io.puts("Hello world! "+line ) > > end > > end > > end > > > > > server =3D BasicServer.new(1234) > > server.start > > server.join > > > > Client : > > require "socket" > > print("Connexion...") > > clientsock =3D TCPsocket.open("localhost", 1234) > > print(" termin=E9e\n") > > clientsock.write("toto") > > The problem is that in the server you are doing a io.gets, so it's > waiting for a \n, which write doesn't produce. Try this: > > clientsock.puts("toto") > > > > puts(clientsock.gets) > > clientsock.close > > > Jesus. > > --0016363b9bce5d3e610485f307b5--