Method: OpenC3::TcpipServerInterface#initialize

Defined in:
lib/openc3/interfaces/tcpip_server_interface.rb

#initialize(write_port, read_port, write_timeout, read_timeout, protocol_type = nil, *protocol_args) ⇒ TcpipServerInterface

Returns a new instance of TcpipServerInterface.

Parameters:

  • write_port (Integer)

    The server write port. Clients should connect and expect to receive data from this port.

  • read_port (Integer)

    The server read port. Clients should connect and expect to send data to this port.

  • write_timeout (Float)

    Seconds to wait before aborting writes

  • read_timeout (Float|nil)

    Seconds to wait before aborting reads. Pass nil to block until the read is complete.

  • protocol_type (String) (defaults to: nil)

    The name of the stream to use for both the read and write ports. This name is combined with 'Protocol' to result in a OpenC3 Protocol class.

  • protocol_args (Array)

    Arguments to pass to the Protocol



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/openc3/interfaces/tcpip_server_interface.rb', line 73

def initialize(write_port,
               read_port,
               write_timeout,
               read_timeout,
               protocol_type = nil,
               *protocol_args)
  super(protocol_type, protocol_args)
  @write_port = ConfigParser.handle_nil(write_port)
  @write_port = Integer(write_port) if @write_port
  @read_port = ConfigParser.handle_nil(read_port)
  @read_port = Integer(read_port) if @read_port
  @write_timeout = ConfigParser.handle_nil(write_timeout)
  @write_timeout = @write_timeout.to_f if @write_timeout
  @read_timeout = ConfigParser.handle_nil(read_timeout)
  @read_timeout = @read_timeout.to_f if @read_timeout
  @listen_sockets = []
  @listen_pipes = []
  @listen_threads = []
  @read_threads = []
  @write_thread = nil
  @write_raw_thread = nil
  @write_interface_infos = []
  @read_interface_infos = []
  @write_queue = nil
  @write_queue = Queue.new if @write_port
  @write_raw_queue = nil
  @write_raw_queue = Queue.new if @write_port
  @read_queue = nil
  @read_queue = Queue.new if @read_port
  @write_condition_variable = nil
  @write_condition_variable = ConditionVariable.new if @write_port
  @write_raw_mutex = nil
  @write_raw_mutex = Mutex.new if @write_port
  @write_raw_condition_variable = nil
  @write_raw_condition_variable = ConditionVariable.new if @write_port
  @write_connection_callback = nil
  @read_connection_callback = nil
  @stream_log_pair = nil
  @raw_logging_enabled = false
  @connection_mutex = Mutex.new
  @listen_address = "0.0.0.0"

  @read_allowed = false unless ConfigParser.handle_nil(read_port)
  @write_allowed = false unless ConfigParser.handle_nil(write_port)
  @write_raw_allowed = false unless ConfigParser.handle_nil(write_port)

  @connected = false
end