[MacRuby] #754: TCP socket is disconnected when used IO#gets and IO#puts.
#754: TCP socket is disconnected when used IO#gets and IO#puts. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- {{{ require 'socket' host = "127.0.0.1" port = 10000 serv = TCPServer.new(host, port) s = serv.accept loop do line = s.gets s.puts("PUT: " + line) exit if(line.chomp == "quit") end }}} I connected to above echo server with telnet, then typed words. {{{ $ telnet 127.0.0.1 10000 hello world PUT: hello world Connection closed by foreign host. }}} A socket is disconnected when used IO#gets and IO#puts. -- Ticket URL: <http://www.macruby.org/trac/ticket/754> MacRuby <http://macruby.org/>
#754: TCP socket is disconnected when used IO#gets and IO#puts. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by watson1978@…): It seems behaviors of MacRuby's IO#gets as follows: 1. At first time IO#gets calls * CFDataGetLength(io_struct->buf) is 0 and calls read_internal(). * IO#gets is waited by read_internal() that data is input. 2. At second times IO#gets calls * Output data is stored in io_struct->buf with IO#puts immediately before.[[BR]] So, CFDataGetLength(io_struct->buf) is not 0 and does not call read_internal(). * IO#gets is not waited. * IO#gets gets a 0 byte data from io_struct->buf. Its data seems a nil class. 3. IO#puts and chomp are called for nil, and the exception is generated. -- Ticket URL: <http://www.macruby.org/trac/ticket/754#comment:1> MacRuby <http://macruby.org/>
#754: TCP socket is disconnected when used IO#gets and IO#puts. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by watson1978@…): I attach a patch file. I conform only that test script works. So, I think that this patch may have a problem. -- Ticket URL: <http://www.macruby.org/trac/ticket/754#comment:2> MacRuby <http://macruby.org/>
#754: TCP socket is disconnected when used IO#gets and IO#puts. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by watson1978@…): It seems this issue blocks a #696. -- Ticket URL: <http://www.macruby.org/trac/ticket/754#comment:3> MacRuby <http://macruby.org/>
#754: TCP socket is disconnected when used IO#gets and IO#puts. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.7 Component: MacRuby | Resolution: fixed Keywords: | ----------------------------------+----------------------------------------- Changes (by martinlagardette@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.7 Comment: Fixed with r4342. But the initial idea of the patch was pretty close to the fix :-). Thanks! -- Ticket URL: <http://www.macruby.org/trac/ticket/754#comment:4> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby