Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix abstract def parameter name in LibEvent::EventLoop#send_to #14658

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading