Skip to content

Commit

Permalink
Datagram support for UNIXServer (#11426)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlhoerberg authored Nov 29, 2021
1 parent 35afca6 commit 70105e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/std/socket/unix_server_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,18 @@ describe UNIXServer do
end
end
end

describe "datagrams" do
it "can send and receive datagrams" do
with_tempfile("unix_dgram_server.sock") do |path|
UNIXServer.open(path, Socket::Type::DGRAM) do |s|
UNIXSocket.open(path, Socket::Type::DGRAM) do |c|
c.send("foobar")
msg, _addr = s.receive(512)
msg.should eq "foobar"
end
end
end
end
end
end
1 change: 1 addition & 0 deletions src/socket/unix_server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class UNIXServer < UNIXSocket
raise error
end

return if type == Type::DGRAM
listen(backlog) do |error|
close
raise error
Expand Down

0 comments on commit 70105e6

Please sign in to comment.