| 113 | } |
| 114 | |
| 115 | int accept(int fd, struct sockaddr *addr, socklen_t *addrlen, |
| 116 | Timeout timeout) { |
| 117 | #ifdef __APPLE__ |
| 118 | auto ret = DOIO_ONCE(::accept(fd, addr, addrlen), |
| 119 | wait_for_fd_readable(fd, timeout)); |
| 120 | if (ret > 0) { |
| 121 | set_fd_nonblocking(ret); |
| 122 | int val = 1; |
| 123 | ::setsockopt(ret, SOL_SOCKET, SO_NOSIGPIPE, (void*)&val, sizeof(val)); |
| 124 | } |
| 125 | return ret; |
| 126 | #else |
| 127 | return DOIO_ONCE(::accept4(fd, addr, addrlen, SOCK_NONBLOCK), |
| 128 | wait_for_fd_readable(fd, timeout)); |
| 129 | #endif |
| 130 | } |
| 131 | |
| 132 | ssize_t read(int fd, void *buf, size_t count, Timeout timeout) { |
| 133 | return DOIO_ONCE(::read(fd, buf, count), wait_for_fd_readable(fd, timeout)); |