| 73 | } |
| 74 | |
| 75 | int socket(int domain, int type, int protocol) { |
| 76 | #ifdef __APPLE__ |
| 77 | auto fd = ::socket(domain, type, protocol); |
| 78 | set_fd_nonblocking(fd); |
| 79 | int val = 1; |
| 80 | ::setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, (void*)&val, sizeof(val)); |
| 81 | return fd; |
| 82 | #else |
| 83 | return ::socket(domain, type | SOCK_NONBLOCK, protocol); |
| 84 | #endif |
| 85 | } |
| 86 | int connect(int fd, const struct sockaddr *addr, socklen_t addrlen, |
| 87 | Timeout timeout) { |
| 88 | int err = 0; |