2021-04-30 13:08:49 +01:00
|
|
|
const std = @import("std.zig");
|
|
|
|
|
2021-04-30 10:17:39 +01:00
|
|
|
pub const os = struct {
|
std/os, x/os/socket: windows support, socket helpers, getpeername()
Socket I/O methods such as read, readv, write, writev, send, recv,
sendmsg, recvmsg have been generalized to read(buf, flags), write(buf,
flags), readVectorized(vectors, flags), and writeVectorized(vectors,
flags). There is still some work left to be done abstracting both
readVectorized and writeVectorized properly across platforms, which is
work to be done in a future PR.
Support for setting the linger timeout of a socket, querying the remote
address of a socket, setting whether or not keep-alive messages are to
be sent through a connection-oriented socket periodically depending on
host operating system settings has been added.
`std.io.Reader` and `std.io.Writer` wrappers around `Socket` has been
implemented, which wrap around Socket.read(buf, flags) and
Socket.write(buf, flags). Both wrappers may be provided flags which are
passed to Socket.read / Socket.write accordingly.
Cross-platform support for `getpeername()` has been implemented.
Windows support for the new `std.x.os.Socket` has been implemented. To
accomplish this, a full refactor of `std.os.windows.ws2_32` has been
done to supply any missing definitions and constants based on
auto-generated Windows syscall bindings by @marler8997.
`std.x.net.TCP.Listener.setQuickACK` has been moved to
`std.x.net.TCP.Client.setQuickACK`.
Windows support for resolving the scope ID of an interface name
specified in an IPv6 address has been provided.
`sockaddr_storage` definitions have been provided for Windows, Linux,
and Darwin. `sockaddr_storage` is used to allocate space before any
socket addresses are queried via. calls such as accept(), getsockname(),
and getpeername().
Zig-friendly wrappers for GetQueuedCompletionStatusEx(), getpeername(),
SetConsoleCtrlHandler(), SetFileCompletionNotificationModes() syscalls
on Windows have been provided.
Socket.setOption() was provided to set the value of a socket option in
place of os.setsockopt. Socket.getOption() will be provided in a future
PR.
There is still further work to be done regarding querying socket option
values on Windows, which is to be done in a subsequent PR.
2021-05-08 14:44:39 +01:00
|
|
|
pub const Socket = @import("x/os/socket.zig").Socket;
|
x/io, x/os: async i/o reactor, cross-platform socket syscalls and bits
Cross-platform versions of msghdr, sendmsg, recvmsg, linger, and iovec
were provided based on findings from glibc, musl, and Microsoft's
documentation.
Implemented initial Reactor interface for epoll (linux) which wraps
around I/O reactor subsystems such as epoll, kqueue, select, etc. across
different platforms. The Reactor interface allows for driving async I/O
in Zig applications.
A test was added for the Reactor interface to drive a TCP
client/listener socket pair.
A greatest-common-subset of possible socket initialization flags (close
socket on exec syscalls, initialize socket to be non-blocking) were
implemented.
A test was added for using sendmsg/recvmsg syscalls across different
platforms for a TCP client/listener socket pair.
2021-05-12 14:43:34 +01:00
|
|
|
pub usingnamespace @import("x/os/io.zig");
|
2021-04-30 10:17:39 +01:00
|
|
|
pub usingnamespace @import("x/os/net.zig");
|
|
|
|
};
|
|
|
|
|
|
|
|
pub const net = struct {
|
2021-05-02 10:51:32 +01:00
|
|
|
pub const ip = @import("x/net/ip.zig");
|
2021-04-30 13:08:49 +01:00
|
|
|
pub const tcp = @import("x/net/tcp.zig");
|
2022-01-22 07:14:07 +00:00
|
|
|
pub const bpf = @import("x/net/bpf.zig");
|
2021-04-30 10:17:39 +01:00
|
|
|
};
|
2021-04-30 13:08:49 +01:00
|
|
|
|
|
|
|
test {
|
|
|
|
inline for (.{ os, net }) |module| {
|
|
|
|
std.testing.refAllDecls(module);
|
|
|
|
}
|
|
|
|
}
|