hemant
4/8/2008 9:33:00 AM
Here is our sample server program:
#server code
require 'socket'
serv = TCPServer.new(2202)
if(sock = serv.accept)
p sock.read(4)
sock.close
end
serv.close
# client code
require "socket"
a = TCPSocket.open("localhost",2202)
b = a.write("Hello")
p b
sleep(10)
p a.closed?
b = a.write("hello") #line no 8
p b
write in client succeeds on line#8 silently, without raising an
exception and number of written bytes also seems correct even though
server socket is closed.
For next write Ruby will usually raise EPIPE, but it means that almost
ALWAYS you stand to loose one message. Now on #rubinius, Eric Hodel
mentioned that it could be intentional. But I fail to see how so?
PS: After getting no response on ruby-core for about 4 days, I am
bumping this thread on ruby-talk, hoping to see if its indeed a bug or
I am doing something wrong.