Included modules
Public Class methods
new(ip, port, options)
[show source]
# File lib/httpx/io/udp.rb 9 def initialize(ip, port, options) 10 @host = ip 11 @port = port 12 @io = UDPSocket.new(IPAddr.new(ip).family) 13 @options = options 14 end
Public Instance methods
read(size, buffer)
[show source]
# File lib/httpx/io/udp.rb 51 def read(size, buffer) 52 ret = @io.recvfrom_nonblock(size, 0, buffer, exception: false) 53 return 0 if ret == :wait_readable 54 return if ret.nil? 55 56 log { "READ: #{buffer.bytesize} bytes..." } 57 58 buffer.bytesize 59 rescue IOError 60 end
write(buffer)
In JRuby, sendmsg_nonblock is not implemented
[show source]
# File lib/httpx/io/udp.rb 32 def write(buffer) 33 siz = @io.send(buffer.to_s, 0, @host, @port) 34 log { "WRITE: #{siz} bytes..." } 35 buffer.shift!(siz) 36 siz 37 end