This is a created article in which the information may have evolved or changed.
Recently tried to implement the SS with go, involving socks related APIs, here to summarize the socks programming need to pay attention to the points of knowledge.
- Socks five-tuple: src_ip Source IP src_port Source port dst_ip Destination IP dst_port Destination Port protocol Transport Protocol (TCP/UDP), any one of these five is different socks, does not conflict
- From the previous article, it is known that TCP and UDP can use the same port independently of each other, because protocol is different
- The Listen and dial src_port must be different ports in the go language, or they will be error-
- Read will block until the connection port or EOF (stream end)
- The byte order has the big end and the small side, the big end is the positive sequence, the small terminal is the reverse order, the network transmission generally follows the endian
- Once read data is not necessarily a write data, do not imagine the size of the packet, TCP is guaranteed to be delivered sequentially, the data is defined by the application layer itself, such as HTTP Content-length
- Dial if you do not specify a port, then randomly a 1024--65535 range of ports (want to see how this is achieved in go, grilled a discovery is filled 0 and then the system level to achieve)
- Go TCP interface side dial side listen, build socks read and write better understanding; we all know that UDP is not connected, but the UPD interface in go, dial and listen return conn, and read and write on the conn like TCP, so designed to unify the interface, User-friendly, dot may be a little different from intuition