生命不止,继续go go go!!!
不要问我net包和net/http包的区别,我们先会用,两者的区别慢慢去体会。
net包有什么作用?
Package net provides a portable interface for network I/O, including TCP/IP, UDP, domain name resolution, and Unix domain sockets.
Although the package provides access to low-level networking primitives, most clients will need only the basic interface provided by the Dial, Listen, and Accept functions and the associated Conn and Listener interfaces.
下面介绍几个方法
Dial
语法:
func Dial(network, address string) (Conn, error)
作用:Dial connects to the address on the named network.
例子:
Dial("tcp",