O'Reilly logo

Hands-On System Programming with Go by Alex Guerrieri

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

TCP connections

The TCP is the protocol that is most used on the internet, and it enables delivery of data (bytes) that are ordered. The main focus of this protocol is reliability, which is obtained by establishing a two-way communication, where the receiver sends an acknowledgement signal each time it receives a datagram successfully. 

A new connection can be created using the net.Dial function. It is a generic function that accepts different networks, such as the following:

  • tcp, tcp4 (IPv4-only), tcp6 (IPv6-only)
  • udp, udp4 (IPv4-only), udp6 (IPv6-only)
  • ip, ip4 (IPv4-only), ip6 (IPv6-only)
  • unix (socket stream), unixgram (socket datagram), and unixpacket (socket packet)

A TCP connection can be created, specifying the tcp protocol, together ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required