"Golang Basics" socks programming-related knowledge points

Source: Internet
Author: User
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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.