1 require File.dirname(__FILE__) + '/../../../spec_helper'
2 require File.dirname(__FILE__) + '/../fixtures/classes'
4 describe "UDPSocket.send" do
7 @server_thread = Thread.new do
8 @server = UDPSocket.open
9 @server.bind(nil, SocketSpecs.port)
11 @msg = @server.recvfrom(64)
14 Thread.pass while @server_thread.status and !@ready
17 it "sends data in ad hoc mode" do
18 @socket = UDPSocket.open
19 @socket.send("ad hoc", 0, SocketSpecs.hostname,SocketSpecs.port)
23 @msg[0].should == "ad hoc"
24 @msg[1][0].should == "AF_INET"
25 @msg[1][1].should be_kind_of(Fixnum)
26 @msg[1][3].should == "127.0.0.1"
29 it "sends data in connection mode" do
30 @socket = UDPSocket.open
31 @socket.connect(SocketSpecs.hostname,SocketSpecs.port)
32 @socket.send("connection-based", 0)
36 @msg[0].should == "connection-based"
37 @msg[1][0].should == "AF_INET"
38 @msg[1][1].should be_kind_of(Fixnum)
39 @msg[1][3].should == "127.0.0.1"