Method: Server#initialize
- Defined in:
- lib/steam/servers/server.rb
#initialize(address, port = nil) ⇒ Object
Creates a new server instance with the given address and port
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/steam/servers/server.rb', line 34 def initialize(address, port = nil) address = address.to_s address, port = address.split(':', 2) if address.include? ':' @host_names = [] @ip_addresses = [] @ip_index = 0 @port = port Socket.getaddrinfo(address, port, Socket::AF_INET, Socket::SOCK_DGRAM). each do |address| @host_names << address[2] @ip_addresses << address[3] end @ip_address = @ip_addresses.first init_socket end |