[BUG] Seek error writing to sockets and pipes
Reported by Adam Gardiner | April 15th, 2008 @ 06:19 PM | in 0.10
A seek error results on a socket when an attempt is made to write to a socket on which there is also data still to be read. On MatzRuby, no error occurs.
The exception on RBX is as follows:
Unable to seek (ESPIPE)
Backtrace:
IO(TCPSocket)#seek at kernel/core/io.rb:507
IO(TCPSocket)#write at kernel/core/io.rb:490
IO(TCPSocket)#puts {} at kernel/core/io.rb:371
Array#each at kernel/core/array.rb:573
IO(TCPSocket)#puts at kernel/core/io.rb:355
Object#__script__ at /home/ads/test_client.rb:10
CompiledMethod#as_script at kernel/core/compiled_method.rb:326
Compile.single_load at kernel/core/compile.rb:238
Compile.load_from_extension at kernel/core/compile.rb:310
Object#__script__ at kernel/loader.rb:201
The following server and client code can be used to reproduce the problem:
******* Server code *******
require 'socket'
REMOTE_DEBUG_PORT = 1098
TEST_DATA = <<-END
Here
is
some
multi-line
data
END
port = ARGV.shift || REMOTE_DEBUG_PORT
server = TCPServer.open(port)
puts "*** waiting for client..."
socket = server.accept
puts "Sending data"
TEST_DATA.each_line {|l| socket.puts l}
socket.flush
resp = socket.gets
socket.close
******* Client code *******
require 'socket'
host = ARGV[0] || 'localhost'
port = ARGV[1] || 1098
socket = TCPSocket.new(host, port)
puts "Connected to server on #{host}:#{port}"
while line = socket.gets
puts line
socket.puts line
end
socket.close
Comments and changes to this ticket
-
Benjamin Stiglitz April 16th, 2008 @ 10:43 AM
IO’s buffering is getting in a fight with the socket IO. I might be able to take a look at this.
-
Benjamin Stiglitz April 16th, 2008 @ 01:21 PM
- → Title changed from [BUG] Seek error writing to socket to [BUG] Seek error writing to sockets and pipes
Defiler and I came up with #seekable? as a good sentinel in IO. This bug also affects pipes.
-
-
Wilson Bilkovich May 14th, 2008 @ 09:39 AM
Hrm. This has some CI failures, because it looks like syswrite needs to not rewind. Could you take another look?
See 1.8/core/io/syswrite_spec.rb for some of the failures.
-
Wilson Bilkovich June 25th, 2008 @ 10:24 AM
- → Tag changed from to bug socket
- → Milestone changed from 1.0 preview to 0.10
Example code still breaks in Rubinius, as of today.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
