localhost vs real ip address

When you access localhost, your /etc/hosts file will tell your computer not to look any further and redirects you to your own computer. When you access the local IP adress, your computer will ask the router to fetch the data, and your router will then point back to your computer.

TCP stream vs UDP message

The interface/API presented to you the user(programmer) of these protocols are: UDP Message oriented, you have an API (send/recv and similar) that provide you with the ability to send one datagram, and receive one datagram. 1 send() call results in 1 datagram sent, and 1 recv() call will recieve exactly 1 datagram. TCP Stream oriented, … Read more

How to know TCP connection is closed in net package?

That thread “Best way to reliably detect that a TCP connection is closed“, using net.Conn for ‘c‘ (also seen in utils/ping.go or locale-backend/server.go or many other instances): one := make([]byte, 1) c.SetReadDeadline(time.Now()) if _, err := c.Read(one); err == io.EOF { l.Printf(logger.LevelDebug, “%s detected closed LAN connection”, id) c.Close() c = nil } else { … Read more