Sending a tokio::net::TcpStream to a remote process

32 Views Asked by At

I'm trying to figure out whether it's possible to send a tokio::net::TcpStream or a standard std::net::TcpStream to a remote process in Windows.

I figure that I can:

  1. Get the raw socket for the stream with as_raw_socket()
  2. Pass it to WSADuplicateSocket() 3 .Send the WSAPROTOCOL_INFO struct to the remote process
  3. Pass it to WSASocket to create a socket duplicate in the remote process
  4. Create a std::net::TcpStream by passing the returned SOCKET to from_raw_socket()
  5. Create a tokio::net::TcpStream with from_std()

Does that make any sense?

I tried that and I'm able to get a tokio::net::TcpStream eventually but then when I try sending data on the remote end I'm getting a ConnectionReset error as if the other end (the one which duplicated the socket) has dropped the connection.

0

There are 0 best solutions below