void HandleConnection()
	{
		cout << "You are connected !!!" << endl;
		char temp[30];
		Recv(temp, sizeof(temp));
		if(temp[0] == 5) // test for version
		{
			cout << "Version good" << endl;
			char* reply = new char[2];
			reply[0] = 5; // version
			reply[1] = 0; // method choosed (no auth required)
			Send(reply, sizeof(reply));
			delete [] reply;
			memset(temp, '\0', sizeof(temp));
			Recv(temp, sizeof(temp));
			temp[sizeof(temp) + 1] = '\0';
			if(temp[0] == 5) // test for version
			{
				if(temp[4] == 14) // test for lenght of www.google.com
				{
					char* domain = new char[temp[4] + 1];
					for(int i = 0; i < temp[4]; ++i)
					{
						domain[i] = temp[i + 5]; // copy domain name
					}
					domain[15] = '\0';
					cout << endl;
					cout << domain << endl;
					int domainLen = strlen(domain);
					//with this packet i get a warning that i send an unexpected answer
					char* reply = new char[domainLen + 6];
					reply[0] = 5; // version
					reply[1] = 0; // succed
					reply[2] = 0; // reserved
					reply[3] = 3; // its a domain
					reply[4] = domainLen; // lenght of domain
					for(int j = 0; j < domainLen; ++j)
					{
						reply[j + 5] = domain[j];
					}
					reply[4 + domainLen] = 80; // port
					reply[sizeof(reply)] = '\0';
					Send(reply, domainLen+1);
					delete [] reply;
				}
			}
		}

	}

I have a problem when i send the last packet,i get a warning sayng that i returned an unexpected answer when trying to connect to google. I use Proxifier to test this.

[06:22] Starting: Test 1: Connection to the Proxy Server
[06:22] IP Address: 127.0.0.1
[06:22] Connection established
[06:22] Test passed.
[06:22] Starting: Test 2: Connection through the Proxy Server
[06:22] Authentication was successful.
[06:22] Warning : the proxy server has returned an unexpected answer (0x32).
[06:22] Connection to www.google.com:80 established through the proxy server.

Anyone know why i get this ?

My mistake,i must Send(reply, domainLen + 6) to work but now i get this error:

Error : the reply that was recieved from the target host does not look like a usual Web Server reply.
	Please make sure that the target host is a Web Server.
	The error may also indicate that the proxy server is not operating properly.
	Target host reply = www.google.c
[35:01] Test failed.

Hi, part of your issue is on line 41.
SOCKS5 protocol requires that the port of the destination server be sent as a two byte segment in network octet form.

Sorry for the late reply / gravedig. This is my first post on this site.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.