Skip to content

Commit

Permalink
jruby does not implement UDPSocket#sendmsg ad #recvmsg_nonblock
Browse files Browse the repository at this point in the history
  • Loading branch information
HoneyryderChuck committed Jan 3, 2025
1 parent d373cf9 commit 5cd42ca
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions lib/netsnmp/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,31 @@ def send(payload)

SOCK_FLAGS = Socket.const_defined?(:MSG_DONTWAIT) ? Socket::MSG_DONTWAIT : 0

def write(payload)
perform_io do
@socket.sendmsg(payload, SOCK_FLAGS, @destaddr)
if RUBY_ENGINE == "jruby"
def write(payload)
perform_io do
@socket.send(payload, SOCK_FLAGS, @destaddr)
end
end
end

def recv(bytesize = MAXPDUSIZE)
perform_io do
datagram, = @socket.recvmsg_nonblock(bytesize, SOCK_FLAGS)
datagram
def recv(bytesize = MAXPDUSIZE)
perform_io do
datagram, = @socket.recv_nonblock(bytesize, SOCK_FLAGS)
datagram
end
end
else
def write(payload)
perform_io do
@socket.sendmsg(payload, SOCK_FLAGS, @destaddr)
end
end

def recv(bytesize = MAXPDUSIZE)
perform_io do
datagram, = @socket.recvmsg_nonblock(bytesize, SOCK_FLAGS)
datagram
end
end
end

Expand Down

0 comments on commit 5cd42ca

Please sign in to comment.