blob: bfef66f6668da3cf5c728fc36f64931bfbd30f87 [file] [log] [blame]
William A. Kennington IIIeac9d472020-08-03 13:57:14 -07001#include <fcntl.h>
2#include <fmt/format.h>
Patrick Williamsd1984dd2023-05-10 16:12:44 -05003#include <sys/socket.h>
4
William A. Kennington IIIeac9d472020-08-03 13:57:14 -07005#include <stdplus/fd/create.hpp>
6#include <stdplus/util/cexec.hpp>
William A. Kennington IIIeac9d472020-08-03 13:57:14 -07007
8namespace stdplus
9{
10namespace fd
11{
12
13DupableFd open(const char* pathname, OpenFlags flags, mode_t mode)
14{
15 return DupableFd(
16 CHECK_ERRNO(::open(pathname, static_cast<int>(flags), mode),
17 fmt::format("open `{}`", pathname)));
18}
19
20DupableFd socket(SocketDomain domain, SocketType type, SocketProto protocol)
21{
22 return DupableFd(
23 CHECK_ERRNO(::socket(static_cast<int>(domain), static_cast<int>(type),
24 static_cast<int>(protocol)),
25 "socket"));
26}
27
28} // namespace fd
29} // namespace stdplus