Skip to content

Conversation

fangyinc
Copy link

@fangyinc fangyinc commented Jul 21, 2025

  1. Support IPv6 protocol
  2. Maintain compatibility with the previous API version (Recommended to replace @socket.Addr with @socket.SocketAddr)

@fangyinc
Copy link
Author

Hi @Guest0x0, please review codes.

@fangyinc
Copy link
Author

@Guest0x0 The latest code has been merged and conflicts have been resolved. Feel free to ask if you have any questions!

@Guest0x0
Copy link
Collaborator

Guest0x0 commented Sep 4, 2025

Sorry for the late reply, I thought this was the old one. Will review soon.

moonbitlang_get_ip_addr_detail(
const struct sockaddr *src,
moonbit_get_ip_name_port_cb_t *cb)
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this function is unnecessary and too complex. ai_family, port, etc. can be accessed via simple getter functions


///|
#deprecated("Use @socket.SocketAddr instead, it will be removed after 0.2.0")
pub typealias SocketAddr as Addr
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the motivation behind the renaming here

@@ -214,7 +214,7 @@ test "spawn_loop cancelled2" {
log.write_object(
try? @async.with_event_loop(fn(root) {
let mut i = 0
root.spawn_loop(no_wait=true, allow_failure=true, retry=FixedDelay(50), fn() {
root.spawn_loop(no_wait=true, allow_failure=true, retry=FixedDelay(50), () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

irrelevant diff

@Guest0x0
Copy link
Collaborator

Guest0x0 commented Sep 4, 2025

Since the @socket package has changed quite a lot, could you do a rebase first? In particular, the TCP API has changed a bit, the raw socket concept was hidden, and the address for listen/connect is provided on creation of TCPServer and TCP. So we can now infer the domain of a socket from the address.

BTW, I think we can just keep using Bytes for @socket.Addr, since Bytes can have variable length. This is also how the C API works. IPv6 and IPv4 address will correspond to Bytes of different length, and we can tell their kind via the sin_family field

@fangyinc
Copy link
Author

fangyinc commented Sep 4, 2025

Since the @socket package has changed quite a lot, could you do a rebase first? In particular, the TCP API has changed a bit, the raw socket concept was hidden, and the address for listen/connect is provided on creation of TCPServer and TCP. So we can now infer the domain of a socket from the address.
BTW, I think we can just keep using Bytes for @socket.Addr, since Bytes can have variable length. This is also how the C API works. IPv6 and IPv4 address will correspond to Bytes of different length, and we can tell their kind via the sin_family field

Great suggestion. I need some time to provide IPv6 support based on the latest code of the @socket package.

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.

2 participants