Monday, September 5, 2011

Simple socks5 server in C++

This is a socks5 proxy server i implemented a few months ago. It's developed in C++, and as far as i have tested, works pretty well. There are a couple of things left to do, like handling domain name connection requests, or do a better thread handling, but it has served its purpose so far.

In order to compile it, you can use the GNU C++ compiler, and linking the application with libpthread:
g++ -o socks5 socks5.cpp -lpthread
By default it only accepts authenticated connections, using the USERNAME define as username, and the PASSWORD define as password. If you want to allow unauthenticated connection requests, add a -DALLOW_NO_AUTH flag when compiling.

The proxy server listens on port 5555, you might as well want to change the SERVER_PORT define if you want it to wait for connections on another port.

The source code can be downloaded from github:

Hope you find it useful!


  1. where is example clien in C?
    is possible to write client and server in one program?

    1. You could use proxychains(, or some other proxyfier tool.

  2. Hi! Do you have you an example for Windows?

  3. I will conver to windows, complied success and run fine, port listening success! I really upload on windows server and run it and using tools check socks5 online and check this but not work any socks version.

    myserverip:27999 HTTP: proxy does not work!
    myserverip:27999 SOCKS 4: proxy does not work!
    myserverip:27999 SOCKS 5: proxy does not work!

    you can tell my why??

    1. Could it be a firewall problem? Are connections to port 27999 allowed through the firewall?

    2. Yeb, i will disabled all firewall and check port at and success connection to port 27999 but can not using for socks proxy any version. Here is my code.

      Full source:
      File Main.cpp:

      I using codeBlock for coding.

  4. It does not work!.it listens in port,and then when i try to use it with proxifier i get the following response:

    26:56] Starting: Test 1: Connection to the Proxy Server
    [26:56] IP Address:
    [26:57] Connection established
    [26:57] Test passed.
    [26:57] Starting: Test 2: Connection through the Proxy Server
    [26:57] Authentication was successful.
    [26:58] Error : connection to the proxy server was closed unexpectedly.
    [26:58] Test failed.
    [26:58] Testing Finished.

    Server: Linux 2.6.18-238.9.1.el5 #1 SMP Tue Apr 12 18:10:13 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
    CentOS release 5.10 (Final)

  5. cuando lo compilo:
    Target is up to date.
    Nothing to be done (all items are up-to-date).

    cuando lo ejecuto:
    [-] Bind error.
    [-] Failed to create server

    Process returned 1 (0x1) execution time : 0.010 s
    Press any key to continue.

    No funciona creo pero se puede actualizar creo que necesitaria una actualizacion una pena porque me gustaba mucho

    1. If you get a bind error then you're either trying to bind to a port where there's already another server running, or you're trying to bind to a port < 1024, for which you would normally need to be root. Just use a higher port number or a port where nothing is running.

  6. Average Coder: Simple Socks5 Server In C++ >>>>> Download Now

    >>>>> Download Full

    Average Coder: Simple Socks5 Server In C++ >>>>> Download LINK

    >>>>> Download Now

    Average Coder: Simple Socks5 Server In C++ >>>>> Download Full

    >>>>> Download LINK c0