Skip to content

Commit

Permalink
Fix: generic Socket#accept? is broken (#6277)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbaddaden authored and RX14 committed Jun 28, 2018
1 parent b0d67e1 commit bf85d7a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions spec/std/socket_spec.cr
Expand Up @@ -74,6 +74,19 @@ describe Socket do
sock.type.should eq(Socket::Type::DGRAM)
end
end

it ".accept" do
server = Socket.new(Socket::Family::INET, Socket::Type::STREAM, Socket::Protocol::TCP)
server.bind("0.0.0.0", 11234)
server.listen

spawn { TCPSocket.new("127.0.0.1", 11234).close }

client = server.accept
client.family.should eq(Socket::Family::INET)
client.type.should eq(Socket::Type::STREAM)
client.protocol.should eq(Socket::Protocol::TCP)
end
end

describe Socket::Addrinfo do
Expand Down
2 changes: 1 addition & 1 deletion src/socket.cr
Expand Up @@ -228,7 +228,7 @@ class Socket < IO
# ```
def accept?
if client_fd = accept_impl
sock = Socket.new(client_fd)
sock = Socket.new(client_fd, family, type, protocol, blocking)
sock.sync = sync?
sock
end
Expand Down

0 comments on commit bf85d7a

Please sign in to comment.