Skip to content

Commit

Permalink
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions spec/std/socket_spec.cr
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/socket.cr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bf85d7a

Please sign in to comment.