Class: Socket::UDPSource

Inherits:
Object
  • Object
show all
Defined in:
lib/socket.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_adress is an Addrinfo object.

local_adress is an Addrinfo object.

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


726
727
728
729
730
# File 'lib/socket.rb', line 726

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


736
737
738
# File 'lib/socket.rb', line 736

def local_address
  @local_address
end

#remote_addressObject (readonly)

Address of the source


733
734
735
# File 'lib/socket.rb', line 733

def remote_address
  @remote_address
end

Instance Method Details

#inspectObject

:nodoc:


738
739
740
# File 'lib/socket.rb', line 738

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


743
744
745
# File 'lib/socket.rb', line 743

def reply(msg)
  @reply_proc.call msg
end