blob: 2240a98b728742c3175738652278bc397cc402d4 [file] [log] [blame]
William A. Kennington IIIeac9d472020-08-03 13:57:14 -07001#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
7namespace stdplus
8{
9namespace fd
10{
11
12DupableFd 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
19DupableFd 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