William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 1 | #include <fcntl.h> |
| 2 | #include <fmt/format.h> |
| 3 | #include <stdplus/fd/create.hpp> |
| 4 | #include <stdplus/util/cexec.hpp> |
| 5 | #include <sys/socket.h> |
| 6 | |
| 7 | namespace stdplus |
| 8 | { |
| 9 | namespace fd |
| 10 | { |
| 11 | |
| 12 | DupableFd open(const char* pathname, OpenFlags flags, mode_t mode) |
| 13 | { |
| 14 | return DupableFd( |
| 15 | CHECK_ERRNO(::open(pathname, static_cast<int>(flags), mode), |
| 16 | fmt::format("open `{}`", pathname))); |
| 17 | } |
| 18 | |
| 19 | DupableFd socket(SocketDomain domain, SocketType type, SocketProto protocol) |
| 20 | { |
| 21 | return DupableFd( |
| 22 | CHECK_ERRNO(::socket(static_cast<int>(domain), static_cast<int>(type), |
| 23 | static_cast<int>(protocol)), |
| 24 | "socket")); |
| 25 | } |
| 26 | |
| 27 | } // namespace fd |
| 28 | } // namespace stdplus |