go language better and better - network [5] -tcpaddr

TCPAddr

type TCPAddr struct {
IP IP
Port int
}

ResolveTCPAddr function creates TCPAddr

image.png

Wherein the parameter is a net "tcp", "tcp4" " tcp6" or one, addr is a string of the host name or IP address of the composition, followed by ":" followed by the port number, for example " www.google.com:80 " or "127.0.0.1:22".

image.png


Client

image.png

image.png

test

image.png

server

image.png

ListenTCP server listening port, Accept on behalf locked, waiting for client connections

image.png

image.png

Multi-threaded server

image.png

image.png

image.png

Guess you like

Origin blog.51cto.com/13784902/2466822