Code:
open_stream (const char *host, unsigned int port)
{
struct addrinfo *res, *addr, hints;
static char service[6];
int sock, ret;
sprintf (service, "%hu", port);
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME;
ret = getaddrinfo (hostname, service, &hints, &res);
if (ret != 0) {
return -1;
}
sock = -1;
for (addr = res; addr; addr = addr->ai_next) {
sock = socket (addr->ai_family, addr->ai_socktype, addr->ai_protocol);
This is the code in question. Now, if I open the stream to the proxy server, then, how will I instruct the proxy to open a connection to the target server? The socket to the proxy server, is pretty simple. But from then on, I have no clue on how to continue...