123456789_123456789_123456789_123456789_123456789_

Class: Socket::UDPSource

Relationships & Source Files
Inherits: Object
Defined in: ext/socket/lib/socket.rb

Overview

UDP/IP address information used by udp_server_loop.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(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.

[ GitHub ]

  
# File 'ext/socket/lib/socket.rb', line 1038

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_address (readonly)

Local address

[ GitHub ]

  
# File 'ext/socket/lib/socket.rb', line 1048

attr_reader :local_address

#remote_address (readonly)

Address of the source

[ GitHub ]

  
# File 'ext/socket/lib/socket.rb', line 1045

attr_reader :remote_address

Instance Method Details

#inspect

This method is for internal use only.
[ GitHub ]

  
# File 'ext/socket/lib/socket.rb', line 1050

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

#reply(msg)

Sends the String msg to the source

[ GitHub ]

  
# File 'ext/socket/lib/socket.rb', line 1055

def reply(msg)
  @reply_proc.call msg
end