Skip to content

Impl socket htonl#1257

Merged
windelbouwman merged 2 commits into
RustPython:masterfrom
SeungUkLee:socket-htonl
Aug 15, 2019
Merged

Impl socket htonl#1257
windelbouwman merged 2 commits into
RustPython:masterfrom
SeungUkLee:socket-htonl

Conversation

@SeungUkLee
Copy link
Copy Markdown
Contributor

For #1176

Add socket method htonl.

Comment thread vm/src/stdlib/socket.rs
}

let host = host.as_bigint().to_u32().unwrap();
Ok(vm.new_int(host.to_be()))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a rust library with the htonl and ntohl functions?

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.

I found htonl and ntohl in socket crate. but it is not very popular.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Okay, maybe stick to this version, until we find a good socket crate. @palaviv do you have any ideas?

Copy link
Copy Markdown
Member

@coolreader18 coolreader18 Aug 15, 2019

Choose a reason for hiding this comment

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

Even from gnu libc, it essentially is this simple of an implementation. Rust's u32::to_be looks basically the same as that libc htonl.

@windelbouwman
Copy link
Copy Markdown
Contributor

Hi @SeungUkLee this change looks good! I had one question about using a library for the htonl function.

@windelbouwman windelbouwman merged commit 45292e8 into RustPython:master Aug 15, 2019
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