| 74 | Return 0 on success, or -1 on error with errno set. */ |
| 75 | |
| 76 | bool Socket::SetCloexec(int desc, bool value) |
| 77 | { |
| 78 | #ifdef __unix__ |
| 79 | int oldflags = fcntl(desc, F_GETFD, 0); |
| 80 | if (oldflags < 0) |
| 81 | return false; |
| 82 | |
| 83 | if (value) |
| 84 | oldflags |= FD_CLOEXEC; |
| 85 | else |
| 86 | oldflags &= ~FD_CLOEXEC; |
| 87 | |
| 88 | return fcntl(desc, F_SETFD, oldflags) >= 0; |
| 89 | #else |
| 90 | return true; |
| 91 | #endif |
| 92 | } |
| 93 | |
| 94 | |
| 95 | bool Socket::GetLocalAddress(SocketAddress* address) const |