Suppose I have a reliable UDP library and you want to tunnel arbitrary TCP connections through it. This is my current approach to this, but I feel that it may not be very effective. Any suggestions are welcome.
- The client establishes a reliable UDP connection to the server.
- The client runs the local SOCKS5 proxy, which receives data from any application that connects to it and forwards it through a reliable UDP connection. Each packet includes a 4-byte identifier unique to each SOCKS connection.
- The server is receiving data. If the 4-byte identifier is new, it establishes a new connection to its local TCP socket and sends the data, and also creates a new stream that receives any responses from the server and forwards them through a reliable UDP connection with the corresponding identifier. If the 4-byte identifier is out of date, it simply sends data over the existing TCP connection.
- The client receives the data by sending it through an existing SOCKS connection with any application that it launched.
Currently, this seems to work for creating simple HTML requests from the browser, but since the server is not directly connected to the client, it cannot tell when the client ends the connection. Is there a better way to do this?
EDITOR: No, this is not homework. And please do not worry if you are not aware of the benefits of reliable UDP libraries or, for that matter, have not heard of them before. Thanks.
c ++ c networking sockets network-programming
user123003
source share