Class: Teien::RemoteInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/teien/core/remote_info.rb

Constant Summary collapse

@@total_cnt =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(con) ⇒ RemoteInfo

Returns a new instance of RemoteInfo.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/teien/core/remote_info.rb', line 10

def initialize(con)
  @ip = nil
  @port = 0
  if con
    @port, @ip = Socket.unpack_sockaddr_in(con.get_peername) if con.get_peername
  else
    @port = 0
    @ip = "dummy ip"
  end
  @connection = con
  @id = @@total_cnt
  @@total_cnt += 1
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



8
9
10
# File 'lib/teien/core/remote_info.rb', line 8

def connection
  @connection
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/teien/core/remote_info.rb', line 5

def id
  @id
end

#ipObject

Returns the value of attribute ip.



6
7
8
# File 'lib/teien/core/remote_info.rb', line 6

def ip
  @ip
end

#portObject

Returns the value of attribute port.



7
8
9
# File 'lib/teien/core/remote_info.rb', line 7

def port
  @port
end