File tree Expand file tree Collapse file tree 1 file changed +2
-18
lines changed
src/client/legacy/connect Expand file tree Collapse file tree 1 file changed +2
-18
lines changed Original file line number Diff line number Diff line change @@ -914,24 +914,8 @@ fn connect(
914914 )
915915 . map_err ( ConnectError :: m ( "tcp bind local error" ) ) ?;
916916
917- #[ cfg( unix) ]
918- let socket = unsafe {
919- // Safety: `from_raw_fd` is only safe to call if ownership of the raw
920- // file descriptor is transferred. Since we call `into_raw_fd` on the
921- // socket2 socket, it gives up ownership of the fd and will not close
922- // it, so this is safe.
923- use std:: os:: unix:: io:: { FromRawFd , IntoRawFd } ;
924- TcpSocket :: from_raw_fd ( socket. into_raw_fd ( ) )
925- } ;
926- #[ cfg( windows) ]
927- let socket = unsafe {
928- // Safety: `from_raw_socket` is only safe to call if ownership of the raw
929- // Windows SOCKET is transferred. Since we call `into_raw_socket` on the
930- // socket2 socket, it gives up ownership of the SOCKET and will not close
931- // it, so this is safe.
932- use std:: os:: windows:: io:: { FromRawSocket , IntoRawSocket } ;
933- TcpSocket :: from_raw_socket ( socket. into_raw_socket ( ) )
934- } ;
917+ // Convert the `Socket` to a Tokio `TcpSocket`.
918+ let socket = TcpSocket :: from_std_stream ( socket. into ( ) ) ;
935919
936920 if config. reuse_address {
937921 if let Err ( e) = socket. set_reuseaddr ( true ) {
You can’t perform that action at this time.
0 commit comments