diff --git a/src/crystal/event_loop/socket.cr b/src/crystal/event_loop/socket.cr index 1f4fc629d8ca..2e3679e615c5 100644 --- a/src/crystal/event_loop/socket.cr +++ b/src/crystal/event_loop/socket.cr @@ -15,6 +15,9 @@ abstract class Crystal::EventLoop # Use `#receive_from` for capturing the source address of a message. abstract def read(socket : ::Socket, slice : Bytes) : Int32 + # Blocks the current fiber until the socket is ready for read. + abstract def wait_readable(socket : ::Socket) : Nil + # Writes at least one byte from *slice* to the socket. # # Blocks the current fiber if the socket is not ready for writing, @@ -25,6 +28,9 @@ abstract class Crystal::EventLoop # Use `#send_to` for sending a message to a specific target address. abstract def write(socket : ::Socket, slice : Bytes) : Int32 + # Blocks the current fiber until the socket is ready for write. + abstract def wait_writable(socket : ::Socket) : Nil + # Accepts an incoming TCP connection on the socket. # # Blocks the current fiber if no connection is waiting, continuing when one