Skip to content

Conversation

cers000
Copy link

@cers000 cers000 commented Oct 17, 2025

and Restructured the code layout of winflag to achieve a more coherent logical flow.

lib/std/net.zig Outdated
Comment on lines 860 to 861
const winFlag = (if (native_os == .windows) 0 else posix.SOCK.CLOEXEC);
const sock_flags = posix.SOCK.DGRAM | nonblock | winFlag;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zig prefers snake_case for variable names (win_flag, not winFlag).

winFlag is also not a great name, considering its a flag that is applied to non-windows systems.

SOCK.STREAM shouldn't have been changed to SOCK.DGRAM; this is TCP.


pub const UdpConnectToAddressError = posix.SocketError || posix.ConnectError;

pub fn udpConnectToAddress(address: Address) UdpConnectToAddressError!Stream {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UDP is connectionless so it doesn't make sense to connect via UDP. Returning a stream also doesn't make sense, as UDP transmits individual datagrams and not a continuous stream of data.

Corrected the variable naming conventions, but currently using the same stream structure for UDP and TCP is out of necessity.
@drunderscore
Copy link

Fairly certain that std.net is being entirely deleted by #25592.

@cers000
Copy link
Author

cers000 commented Oct 18, 2025

@drunderscore But that might be a relatively distant matter, at least it seems so for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants