Project

General

Profile

Backport #670 » socket.diff

rogerdpack (Roger Pack), 02/08/2010 11:13 PM

View differences:

test/socket/test_socket.rb (working copy)
rescue LoadError
end
require 'timeout'
class TestBasicSocket < Test::Unit::TestCase
def inet_stream
sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
......
}
end
end
def test_use_all_available
no_files = 0
server_ports = []
clients = []
deplete_fds = []
begin
Timeout::timeout(20) do
begin
while true
another_server = TCPServer.new 'localhost', nil
port = another_server.addr[1]
client = TCPSocket.new('localhost', port)
server_ports << another_server.accept
clients << client
client.write clients.length
end
rescue Exception => e
# expected
end
number_returned = 0
while number_returned < clients.length
r,w,e = select(server_ports, nil, nil, nil)
for readable in r
read = readable.recv 1024
readable.write read
number_returned += 1
end
end
clients.each_with_index{|client, idx|
received = client.recv(1024)
assert_equal(received, (idx + 1).to_s)
}
end
end
end
end if defined?(Socket)
class TestSocket < Test::Unit::TestCase
win32/win32.h (working copy)
#ifdef __BORLANDC__
#define USE_WINSOCK2
#endif
#ifndef FD_SETSIZE
# define FD_SETSIZE 256 // larger default
#endif
#ifdef USE_WINSOCK2
#include <winsock2.h>
#include <ws2tcpip.h>
(5-5/5)