How to SOCKSify a client

Note: If your client is using UDP to transfer data, you can't use SOCKS. To see if your client uses UDP, search for the string "SOCK_DGRAM" in your source.
  1. At or near the beginning of main(), you can add a call to SOCKSinit().

    You can omit this step; the only reason for calling SOCKSinit() directly is to associate a name with your SOCKS client (rather than the generic "SOCKSclient" default string).

  2. Add the following options to your compile commands:
    -Dconnect=Rconnect -Dgetsockname=Rgetsockname \
    -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten \
    -Drcmd=Rrcmd -Dselect=Rselect

    If you're using a Makefile, add these options to the definition of macro CFLAGS.

    These options replace calls to certain functions with versions that use the SOCKS server:

  3. Link against the SOCKS library by adding -l socks to your link line.

    If you're using a Makefile, simply add this information to the definition of the macro LDFLAGS.

For most programs, the above steps should be sufficient to SOCKSify the package. If the above doesn't work, you may need to look at things a little more closely. The next section describes how the SOCKS library expects to be used.