Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Both of the OOB tests fail in JRuby but pass in MRI and Rubinius (all on linux only). I'm not 100% sure that I've specified the OOB behaviour correctly (but I think so!). Is this a JRuby/Java bug?
- Can someone have a look and let me know what they think, please?
- require File.dirname(__FILE__) + '/../../../spec_helper'
- require File.dirname(__FILE__) + '/../fixtures/classes'
- describe "BasicSocket#recv" do
- it "receives a message from another socket" do
- # TCPServer and TCPSocket both inherit from BasicSocket
- server = TCPServer.new('127.0.0.1', SocketSpecs.port)
- data = nil
- t = Thread.new do
- client = server.accept
- data = client.recv(5)
- client.close
- end
- Thread.pass until t.status == "sleep"
- socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
- socket.send('hello', 0).should == 5
- t.join
- data.should == 'hello'
- socket.close
- server.close
- end
- it "accepts flags to specify unusual receiving behaviour" do
- server = TCPServer.new('127.0.0.1', SocketSpecs.port)
- data = nil
- t = Thread.new do
- client = server.accept
- data = client.recv(5, Socket::MSG_OOB)
- client.close
- end
- Thread.pass until t.status == "sleep"
- socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
- socket.send('helloU', Socket::MSG_OOB)
- t.join
- data.should == 'U'
- socket.close
- server.close
- end
- end
- ----------------
- require File.dirname(__FILE__) + '/../../../spec_helper'
- require File.dirname(__FILE__) + '/../fixtures/classes'
- describe "BasicSocket#send" do
- it "sends a message to another socket and returns the number of bytes sent" do
- # TCPSocket inherits from BasicSocket
- server = TCPServer.new('127.0.0.1', SocketSpecs.port)
- data = nil
- t = Thread.new do
- client = server.accept
- data = client.recv(5)
- client.close
- end
- Thread.pass until t.status == "sleep"
- socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
- socket.send('hello', 0).should == 5
- t.join
- data.should == 'hello'
- socket.close
- server.close
- end
- it "accepts flags to specify unusual sending behaviour" do
- server = TCPServer.new('127.0.0.1', SocketSpecs.port)
- data = nil
- t = Thread.new do
- client = server.accept
- data = client.recv(6)
- client.close
- end
- Thread.pass until t.status == "sleep"
- socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
- socket.send('helloU', Socket::MSG_OOB).should == 6
- t.join
- data.should == 'hello'
- socket.close
- server.close
- end
- end
Add Comment
Please, Sign In to add comment