Skip to content

Commit

Permalink
Fix abstract def parameter name in LibEvent::EventLoop#send_to (#14658
Browse files Browse the repository at this point in the history
)
  • Loading branch information
straight-shoota authored Jun 4, 2024
1 parent 135e908 commit 4bc7202
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/crystal/system/unix/event_loop_libevent.cr
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ class Crystal::LibEvent::EventLoop < Crystal::EventLoop
{bytes_read, ::Socket::Address.from(sockaddr, addrlen)}
end

def send_to(socket : ::Socket, slice : Bytes, addr : ::Socket::Address) : Int32
bytes_sent = LibC.sendto(socket.fd, slice.to_unsafe.as(Void*), slice.size, 0, addr, addr.size)
raise ::Socket::Error.from_errno("Error sending datagram to #{addr}") if bytes_sent == -1
def send_to(socket : ::Socket, slice : Bytes, address : ::Socket::Address) : Int32
bytes_sent = LibC.sendto(socket.fd, slice.to_unsafe.as(Void*), slice.size, 0, address, address.size)
raise ::Socket::Error.from_errno("Error sending datagram to #{address}") if bytes_sent == -1
# to_i32 is fine because string/slice sizes are an Int32
bytes_sent.to_i32
end
Expand Down
2 changes: 1 addition & 1 deletion src/crystal/system/wasi/event_loop.cr
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Crystal::Wasi::EventLoop < Crystal::EventLoop
raise NotImplementedError.new "Crystal::Wasi::EventLoop#receive_from"
end

def send_to(socket : ::Socket, slice : Bytes, addr : ::Socket::Address) : Int32
def send_to(socket : ::Socket, slice : Bytes, address : ::Socket::Address) : Int32
raise NotImplementedError.new "Crystal::Wasi::EventLoop#send_to"
end

Expand Down
8 changes: 4 additions & 4 deletions src/crystal/system/win32/event_loop_iocp.cr
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ class Crystal::Iocp::EventLoop < Crystal::EventLoop
bytes.to_i32
end

def send_to(socket : ::Socket, bytes : Bytes, addr : ::Socket::Address) : Int32
wsabuf = wsa_buffer(bytes)
def send_to(socket : ::Socket, slice : Bytes, address : ::Socket::Address) : Int32
wsabuf = wsa_buffer(slice)
bytes_written = socket.wsa_overlapped_operation(socket.fd, "WSASendTo", socket.write_timeout) do |overlapped|
ret = LibC.WSASendTo(socket.fd, pointerof(wsabuf), 1, out bytes_sent, 0, addr, addr.size, overlapped, nil)
ret = LibC.WSASendTo(socket.fd, pointerof(wsabuf), 1, out bytes_sent, 0, address, address.size, overlapped, nil)
{ret, bytes_sent}
end
raise ::Socket::Error.from_wsa_error("Error sending datagram to #{addr}") if bytes_written == -1
raise ::Socket::Error.from_wsa_error("Error sending datagram to #{address}") if bytes_written == -1

# to_i32 is fine because string/slice sizes are an Int32
bytes_written.to_i32
Expand Down

0 comments on commit 4bc7202

Please sign in to comment.