I'm trying to create multiple tunnels out of a single TCP connection to a SOCKSv4a proxy server in order to keep from closing and reopening a bunch of sockets to the SOCKS proxy.
Something like "Connection: keep-alive". How can I do that? Does the protocol allow it?
No, this is not supported by any version of SOCKS (nor is it supported by HTTP/1.1 CONNECT
method — keep-alive
is ignored for CONNECT
). Once a tunnel is established, it is a straight pass-through of raw data until either the client or server disconnects. You need to open a separate client-proxy connection for each new connection to the server.