The SOCKS library covers only some of the socket functions,
which must be called in a particular order:
Note:
You must use
TCP;
SOCKS doesn't support UDP.
- The first socket function invoked must be either
connect()
or
rcmd().
- If you call connect() on a nonblocking socket, no I/O can
occur on that socket until another connect(), with the same arguments,
returns -1 and sets
errno
to EISCONN.
This is required even if you use
select()
on write to check the readiness of that socket.
- You must call bind() after a successful
connect() call to a host for a specific service.
- You must follow the call to bind() by calls to
getsockname(), listen(), and accept(),
in that order.
Most client programs fit these assumptions very well and can
be SOCKSified without changing the code at all using the steps described in
How to SOCKSify a client.
Some client programs use a bind() before each
connect(). If the bind() is used to
claim a specific port or a specific network interface, the
current SOCKS library can't accommodate such use. Very often
though, such a bind() call is there for no
specific reason and may simply be deleted.