-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std: Add basic smoke test for net functionality #6838
Conversation
lib/std/os/bits/windows.zig
Outdated
@@ -256,6 +256,41 @@ pub const POLLERR = ws2_32.POLLERR; | |||
pub const POLLHUP = ws2_32.POLLHUP; | |||
pub const POLLNVAL = ws2_32.POLLNVAL; | |||
|
|||
pub const SOL_SOCKET = 0xffff; | |||
|
|||
pub const SO_DEBUG = 0x0001; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these come from ws2_32
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I keep losing track of the many places where bits go.
b0b2f31
to
4981453
Compare
std.os.accept already wants to allow null, which matches `man 3p accept`: > address Either a null pointer, or a pointer to a sockaddr structure > where the address of the connecting socket shall be re‐ > turned. > > address_len Either a null pointer, if address is a null pointer, or a > pointer to a socklen_t object which on input specifies the > length of the supplied sockaddr structure, and on output > specifies the length of the stored address. Fixes ziglang#6832.
* Use closeSocket on sockets instead of plain old close, the latter doesn't work on them. * Use winsocket2 everywhere, mingw has no BSD sockets.
We absolutely need to separate the socket handles from the regular file ones, I've just discovered that you have to call x-ref #6600. |
Only if you go via win32; not if you use the native api. |
Isn't winsock the native api? |
the native api is AFD. |
Good lord, the undocumented kernel driver that's not supposed to be used from usermode? |
According to microsoft the entire NTAPI is "not supposed to be used from usermode" and is mostly undocumented. |
It comes from WASI. I think this a good example of something that would benefit from your points in #6600.
idk, it made sense at the time but I'm not prepared to defend the decision. The std.net code is young, untested, unvetted, and certainly will be reworked, probably more than once.
Zig is a project that has slowly gained quality and robustness by iterating and reworking - not by getting the design right the first time. The short answer to all this stuff is: good points, let's improve things. It's all work-in-progress. |
Barely enough testing to make sure
net
doesn't keep on breaking every damn time.The async tests are broken as exepcted, patches welcome.
Open questions:
socket_t
? Are we minting our own faux-libc types? Why notSocketHandle
?IPAddress
struct hold a port? It's an ip address!IPAddress
a wrapper oversockaddr_in
rather than something saner like a fixed-size array of octets? The number of casts and pointer reinterpretations needed to fill/access them is making (me and) the stage1 compiler sick. Zig currently barfs when trying to parse an ip at comptime!Ip6Address
is asockaddr_in6
you always need to resolve it right away...)