Method: OpenC3::UdpInterface#initialize
- Defined in:
- lib/openc3/interfaces/udp_interface.rb
#initialize(hostname, write_dest_port, read_port, write_src_port = nil, interface_address = nil, ttl = 128, write_timeout = 10.0, read_timeout = nil, bind_address = '0.0.0.0') ⇒ UdpInterface
Returns a new instance of UdpInterface.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/openc3/interfaces/udp_interface.rb', line 43 def initialize( hostname, write_dest_port, read_port, write_src_port = nil, interface_address = nil, ttl = 128, # default for Windows write_timeout = 10.0, read_timeout = nil, bind_address = '0.0.0.0' ) super() @hostname = ConfigParser.handle_nil(hostname) if @hostname @hostname = @hostname.to_s @hostname = '127.0.0.1' if @hostname.casecmp('LOCALHOST').zero? end @write_dest_port = ConfigParser.handle_nil(write_dest_port) @write_dest_port = write_dest_port.to_i if @write_dest_port @read_port = ConfigParser.handle_nil(read_port) @read_port = read_port.to_i if @read_port @write_src_port = ConfigParser.handle_nil(write_src_port) @write_src_port = @write_src_port.to_i if @write_src_port @interface_address = ConfigParser.handle_nil(interface_address) if @interface_address && @interface_address.casecmp('LOCALHOST').zero? @interface_address = '127.0.0.1' end @ttl = ttl.to_i @ttl = 1 if @ttl < 1 @write_timeout = ConfigParser.handle_nil(write_timeout) if @write_timeout @write_timeout = @write_timeout.to_f else Logger.instance.warn("Warning: To avoid interface lock, write_timeout can not be nil. Setting to 10 seconds.") @write_timeout = 10.0 end @read_timeout = ConfigParser.handle_nil(read_timeout) @read_timeout = @read_timeout.to_f if @read_timeout @bind_address = ConfigParser.handle_nil(bind_address) if @bind_address && @bind_address.casecmp('LOCALHOST').zero? @bind_address = '127.0.0.1' end @write_socket = nil @read_socket = nil @read_allowed = false unless @read_port @write_allowed = false unless @write_dest_port @write_raw_allowed = false unless @write_dest_port end |