-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.rb
executable file
·41 lines (32 loc) · 850 Bytes
/
test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
load 'Services/ServerInstance.rb'
=begin
load 'Services/Server.class.rb'
def main
server = TCPServer.new( 'localhost', 8888 )
puts 'Scarlet load balancer is running...'
server1 = Server.new('albert','./Services/conf2.json')
loop do
#Server will accept a request
Thread.start(server.accept) do |client|
response = server1.start_server(client)
client.print "\r\n#{response['response']}\r\n"
if ( response['message'] != nil )
client.print response['message']
end
client.close
end
end
end
main
=end
puts 'Started...\n'
@remote_ports = (8888..8889).to_a
@remote_hosts = %w(localhost localhost localhost localhost localhost localhost)
puts @remote_hosts.length
@remote_ports.length.times do |i|
Thread.new {
puts "server #{i}"
Server_Instance.new(@remote_ports[i])
}
end
gets