Skip to content

use std.Io.net.IpAddress instead of making our own - #3056

Merged
IntegratedQuantum merged 55 commits into
PixelGuys:masterfrom
Wunka:innerIpAddress
Aug 2, 2026
Merged

IntegratedQuantum merged 55 commits into
PixelGuys:masterfrom
Wunka:innerIpAddress

Conversation

@Wunka

@Wunka Wunka commented May 8, 2026

Copy link
Copy Markdown
Contributor

This can be seen as a follow up or replacement for #2259
It is also a preparation for #859 and #2338

The last two commits switched from Ip4Address to the generlized IpAddress so that can be reverted if wanted

@Wunka

Wunka commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

@codemob-dev I have taken the liberty to switch the inner type. I don't know if there any requirements for the SocketAddress to work good with #2180 so if you could take a short look?

@Wunka Wunka moved this to Low Priority in PRs to review May 9, 2026
@IntegratedQuantum

Copy link
Copy Markdown
Member

I think this should be done after #2259, there are some changes in here that are breaking (→changing the location of the question mark) and should be discussed.

@IntegratedQuantum IntegratedQuantum moved this from Low Priority to WIP/not ready for review in PRs to review May 18, 2026
@Wunka

Wunka commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

Ok. I will then rebase when #2259 is merged. Just for documentation (not to already start the discussion) the change of the question mark was done so I don't need to implement the format function myself again just to put the ? before the port. That's the only reason

@Wunka Wunka moved this from WIP/not ready for review to High Priority in PRs to review Jul 18, 2026
Comment thread src/network.zig Outdated
fn send(self: Socket, data: []const u8, destination: SocketAddress) void {
const addr = blk: {
var posixAddr: std.Io.Threaded.PosixAddress = undefined;
_ = std.Io.Threaded.addressToPosix(&destination.address, &posixAddr);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The length (return value) should probably be passed into the other functions instead of using @sizeOf

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

both done

Comment thread src/network.zig Outdated
isSymmetricNAT = true;
portString = portString[0 .. portString.len - 1];
}
const port = try (std.fmt.parseUnsigned(u16, portString, 10) catch |err| (defaultPort orelse err));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of ignoring the error when a defaultPort is present, this should only use the default port when the portString.len == 0

@IntegratedQuantum IntegratedQuantum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since the network code is quite attractive to windows issues and you are using new standard library functions, please also find someone to test this on Windows

@IntegratedQuantum IntegratedQuantum moved this from High Priority to In review in PRs to review Jul 30, 2026
@Wunka

Wunka commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

This was tested on the last playsession by a windows user, no problems were reported

@IntegratedQuantum
IntegratedQuantum merged commit f3fb409 into PixelGuys:master Aug 2, 2026
1 check passed
@Wunka
Wunka deleted the innerIpAddress branch August 2, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants