summaryrefslogtreecommitdiff
path: root/ext/socket/basicsocket.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/socket/basicsocket.c')
-rw-r--r--ext/socket/basicsocket.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ext/socket/basicsocket.c b/ext/socket/basicsocket.c
index a8ab3906e1..78e675c0d3 100644
--- a/ext/socket/basicsocket.c
+++ b/ext/socket/basicsocket.c
@@ -623,8 +623,12 @@ bsock_recv(int argc, VALUE *argv, VALUE sock)
* c = TCPSocket.new(addr, port)
* s = serv.accept
* c.send "aaa", 0
- * IO.select([s]) # emulate blocking recv.
- * p s.recv_nonblock(10) #=> "aaa"
+ * begin # emulate blocking recv.
+ * p s.recv_nonblock(10) #=> "aaa"
+ * rescue IO::WaitReadable
+ * IO.select([s])
+ * retry
+ * end
*
* Refer to Socket#recvfrom for the exceptions that may be thrown if the call
* to _recv_nonblock_ fails.
@@ -632,6 +636,10 @@ bsock_recv(int argc, VALUE *argv, VALUE sock)
* BasicSocket#recv_nonblock may raise any error corresponding to recvfrom(2) failure,
* including Errno::EWOULDBLOCK.
*
+ * If the exception is Errno::EWOULDBLOCK or Errno::AGAIN,
+ * it is extended by IO::WaitReadable.
+ * So IO::WaitReadable can be used to rescue the exceptions for retrying recv_nonblock.
+ *
* === See
* * Socket#recvfrom
*/