Мы не используем API такого низкого уровня, мы используем net.Dial.напр.
func main() {
var (
host = "127.0.0.1"
port = "9998"
remote = host + ":" + port
msg string = "test"
)
con, error := net.Dial("tcp4", remote)
if error != nil {
fmt.Printf("Host not found: %s\n", error)
os.Exit(1)
} else {
defer con.Close()
}
in, error := con.Write([]byte(msg))
if error != nil {
fmt.Printf("Error sending data: %s, in: %d\n", error, in)
os.Exit(2)
}
fmt.Println("Connection OK")
}
Или вы можете отследить код $ GOROOT / src / pkg / net / dial.go