是否可以获取失败的tcp net.Dial的最后一跳的地址?

My goal would be to decide whether an unsuccessful TCP connection made with net.Dial (it does not have to be net.Dial) failed due to a firewall/connectivity issue or just failure in the listener.

So essentially I would like to see something similar what I would with tcptraceroute.

  1. timeout (what was the last ip)
  2. open/closed port on dst

Also it would be nice to figure out which network interface (local address) was used for an unsuccessful connection

conn, err := net.Dial("tcp", hostName + ":" + portNum)

if err != nil {
// is it possible to have socket values here
// maybe the last succesful hop before the connection failed?
}

// on succesfull conn it is straightforward
conn.LocalAddr()
conn.RemoteAddr()