Class: Socket::UDPSource

Inherits:
Object
  • Object
show all
Defined in:
lib/socket/mri.rb

Overview

UDP/IP address information used by Socket.udp_server_loop.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(remote_address, local_address, &reply_proc) ⇒ UDPSource

remote_address is an Addrinfo object.

local_address is an Addrinfo object.

reply_proc is a Proc used to send reply back to the source.



798
799
800
801
802
# File 'lib/socket/mri.rb', line 798

def initialize(remote_address, local_address, &reply_proc)
  @remote_address = remote_address
  @local_address = local_address
  @reply_proc = reply_proc
end

Instance Attribute Details

#local_addressObject (readonly)

Local address



808
809
810
# File 'lib/socket/mri.rb', line 808

def local_address
  @local_address
end

#remote_addressObject (readonly)

Address of the source



805
806
807
# File 'lib/socket/mri.rb', line 805

def remote_address
  @remote_address
end

Instance Method Details

#inspectObject

:nodoc:



810
811
812
# File 'lib/socket/mri.rb', line 810

def inspect # :nodoc:
  "\#<#{self.class}: #{@remote_address.inspect_sockaddr} to #{@local_address.inspect_sockaddr}>"
end

#reply(msg) ⇒ Object

Sends the String msg to the source



815
816
817
# File 'lib/socket/mri.rb', line 815

def reply(msg)
  @reply_proc.call msg
end