Created
January 31, 2017 08:04
-
-
Save DoumanAsh/dbb88edb8e3be883fbf0742c56f05723 to your computer and use it in GitHub Desktop.
Socket into/from/as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let family: c_int = 2; | |
let ty: c_int = 1; | |
let proto: c_int = 6; | |
let raw_socket; | |
{ | |
let socket = Socket::new(family, ty, proto).unwrap(); | |
raw_socket = socket.into_raw_socket(); | |
} | |
let socket = unsafe { Socket::from_raw_socket(raw_socket) }; | |
assert_eq!(raw_socket, socket.as_raw_socket()); | |
assert!(socket.close().is_ok()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment