blob: d9b90f00b382e241de60c63b67b0e8eba3c5d17c [file] [log] [blame]
William A. Kennington IIIeac9d472020-08-03 13:57:14 -07001#include <fcntl.h>
Patrick Williamsd1984dd2023-05-10 16:12:44 -05002#include <sys/socket.h>
3
William A. Kennington IIIeac9d472020-08-03 13:57:14 -07004#include <stdplus/fd/create.hpp>
5#include <stdplus/util/cexec.hpp>
William A. Kennington IIIeac9d472020-08-03 13:57:14 -07006
William A. Kennington III6417c632023-07-17 02:56:52 -07007#include <format>
8
William A. Kennington IIIeac9d472020-08-03 13:57:14 -07009namespace stdplus
10{
11namespace fd
12{
13
14DupableFd open(const char* pathname, OpenFlags flags, mode_t mode)
15{
16 return DupableFd(
17 CHECK_ERRNO(::open(pathname, static_cast<int>(flags), mode),
William A. Kennington III6417c632023-07-17 02:56:52 -070018 std::format("open `{}`", pathname)));
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070019}
20
21DupableFd socket(SocketDomain domain, SocketType type, SocketProto protocol)
22{
23 return DupableFd(
24 CHECK_ERRNO(::socket(static_cast<int>(domain), static_cast<int>(type),
25 static_cast<int>(protocol)),
26 "socket"));
27}
28
29} // namespace fd
30} // namespace stdplus