Skip to content

Commit

Permalink
Drop Crystal::System::Socket#system_send (crystal-lang#14637)
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed May 29, 2024
1 parent 6244f33 commit 28fd0dc
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 26 deletions.
2 changes: 0 additions & 2 deletions src/crystal/system/socket.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ module Crystal::System::Socket

# private def system_accept

# private def system_send(bytes : Bytes) : Int32

# private def system_send_to(bytes : Bytes, addr : ::Socket::Address)

# private def system_receive(bytes)
Expand Down
6 changes: 0 additions & 6 deletions src/crystal/system/unix/socket.cr
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ module Crystal::System::Socket
end
end

private def system_send(bytes : Bytes) : Int32
evented_send("Error sending datagram") do
LibC.send(fd, bytes.to_unsafe.as(Void*), bytes.size, 0)
end
end

private def system_send_to(bytes : Bytes, addr : ::Socket::Address)
bytes_sent = LibC.sendto(fd, bytes.to_unsafe.as(Void*), bytes.size, 0, addr, addr.size)
raise ::Socket::Error.from_errno("Error sending datagram to #{addr}") if bytes_sent == -1
Expand Down
6 changes: 0 additions & 6 deletions src/crystal/system/wasi/socket.cr
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ module Crystal::System::Socket
(raise NotImplementedError.new "Crystal::System::Socket#system_accept").as(Int32)
end

private def system_send(bytes : Bytes) : Int32
evented_send("Error sending datagram") do
LibC.send(fd, bytes.to_unsafe.as(Void*), bytes.size, 0)
end
end

private def system_send_to(bytes : Bytes, addr : ::Socket::Address)
raise NotImplementedError.new "Crystal::System::Socket#system_send_to"
end
Expand Down
11 changes: 0 additions & 11 deletions src/crystal/system/win32/socket.cr
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,6 @@ module Crystal::System::Socket
wsabuf
end

private def system_send(message : Bytes) : Int32
wsabuf = wsa_buffer(message)

bytes = overlapped_write(fd, "WSASend") do |overlapped|
ret = LibC.WSASend(fd, pointerof(wsabuf), 1, out bytes_sent, 0, overlapped, nil)
{ret, bytes_sent}
end

bytes.to_i32
end

private def system_send_to(bytes : Bytes, addr : ::Socket::Address)
wsabuf = wsa_buffer(bytes)
bytes_written = overlapped_write(fd, "WSASendTo") do |overlapped|
Expand Down
2 changes: 1 addition & 1 deletion src/socket.cr
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class Socket < IO
# sock.send(Bytes[0])
# ```
def send(message) : Int32
system_send(message.to_slice)
system_write(message.to_slice)
end

# Sends a message to the specified remote address.
Expand Down

0 comments on commit 28fd0dc

Please sign in to comment.