File: What_SOCKS_expects

package info (click to toggle)
socks4-server 4.3.beta2-20
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 1,512 kB
  • ctags: 1,778
  • sloc: ansic: 19,305; makefile: 399; sh: 52
file content (48 lines) | stat: -rw-r--r-- 1,836 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
	What SOCKS Expects In the Client Programs

		    Ying-Da Lee
		<ylee@syl.dl.nec.com>

SOCKS is intended for easy conversion of existing network TCP client
programs.  Towards that end, it expects that the programs are written
in a certain way.

SOCKS only pays attention to six socket functions: connect(), bind(),
getsockname(), listen(), accept(), select(), and rcmd(). (select and
rcmd() do not apply to versions prior to version 4.2 of SOCKS.CSTC.)
SOCKS makes the following assumptions.

1) Everything is done in TCP.

2) The very first function invoked must be connect(), or rcmd().

3) If connect() is used on a non-blocking socket, no I/O should occur
   on that socket until after another connect() with the same arguments
   returns with -1 and errno indicating EISCONN. This is required even
   if select() on write is used to check the readiness of that socket.
   Also, while a connection is still pending, no attempts may
   be made to start another connection via connect() or the bind()--
   getsockname()--listen()--accept() sequence.

4) bind() is used after a successful connect() call to a host for a
   specific service.  It is used to establish an auxiliary TCP
   session with the same host in the previous connect() call and for
   the same service.

5) bind() is followed by

	getsockname()
	listen()
	accept()

   in the order given above.

Most client programs fit these assumptions very well; such programs
can be SOCKSified without changing the code at all using the steps
described in the file How_to_SOCKSified. 

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 is not able to accommodate such use. Very often though,
such a bind() call is there for no reason at all, and should simply
be deleted.