如何使用Go编程语言使用WSASocket函数创建套接字?

Does anyone know how to create a SOCKET as returned by WSASocket() function in go programming language?

Using a normal syscall.Socket type syscall.Bind results in: WSAENOTSOCK - Error 10038 - An operation was attempted on something that is not a socket. The specified socket parameter refers to a file, not a socket.

Thanks

We don't use such low level API, we use net.Dial. ex.

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
", 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
", error, in)
                os.Exit(2)
        }

        fmt.Println("Connection OK")

}

Or, you could trace the code $GOROOT/src/pkg/net/dial.go