April 2012
Intermediate to advanced
288 pages
4h 39m
English
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.
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 ...
Read now
Unlock full access