File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ use std::ffi;
99use std:: fmt;
1010use std:: marker:: PhantomData ;
1111use std:: os:: raw:: c_void;
12+ #[ cfg( unix) ]
13+ use std:: os:: unix:: io:: { AsRawFd , RawFd as UnixRawFd } ;
14+ #[ cfg( windows) ]
15+ use std:: os:: windows:: io:: { AsRawSocket , RawSocket } ;
1216use std:: result;
1317use std:: string:: FromUtf8Error ;
1418use std:: sync:: Arc ;
@@ -480,6 +484,20 @@ impl Drop for Socket {
480484 }
481485}
482486
487+ #[ cfg( unix) ]
488+ impl AsRawFd for Socket {
489+ fn as_raw_fd ( & self ) -> UnixRawFd {
490+ self . get_fd ( ) . unwrap ( ) as UnixRawFd
491+ }
492+ }
493+
494+ #[ cfg( windows) ]
495+ impl AsRawSocket for Socket {
496+ fn as_raw_socket ( & self ) -> RawSocket {
497+ self . get_fd ( ) . unwrap ( ) as RawSocket
498+ }
499+ }
500+
483501macro_rules! sockopt_getter {
484502 ( $( #[ $meta: meta] ) *
485503 pub $getter: ident => $constant_name: ident as $ty: ty
You can’t perform that action at this time.
0 commit comments