Method: OpenC3::UdpReadWriteSocket#read

Defined in:
lib/openc3/io/udp_sockets.rb

#read(read_timeout = nil) ⇒ Object

Parameters:

  • read_timeout (Float) (defaults to: nil)

    Time in seconds to wait for the read to complete



114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/openc3/io/udp_sockets.rb', line 114

def read(read_timeout = nil)
  data = nil
  begin
    data, _ = @socket.recvfrom_nonblock(65536)
  rescue Errno::EAGAIN, Errno::EWOULDBLOCK
    result = IO.fast_select([@socket], nil, nil, read_timeout)
    if result
      retry
    else
      raise Timeout::Error, "Read Timeout"
    end
  end
  data
end