Cover page by David Chisnall

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

13. Network Access

When C was created, computers were rare and expensive. It was still fairly common for a company to have a single computer. Now, a computer that isn’t connected to a network is considered an oddity.

Being able to interact with the network is important for most programs. Go has a variety of packages in the standard library for network access, which is hardly surprising when you consider that Google is the language’s main backer.

Connecting to Servers

 6  func tryConnect(network, host string, port int)         net.Conn { 7    p := strconv.Itoa(port) 8    addr := net.JoinHostPort(host, p) 9    c, e := net.Dial(network, addr)10    if e == nil { return c }11    return nil12  }

From: connect.go

If you ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required