golang';s func(c*IPConn)Write(b[]字节)(int,error))返回?

golang';s func(c*IPConn)Write(b[]字节)(int,error))返回?,go,Go,我猜int是写入的字节数 我认为函数会一直阻塞,直到缓冲区完全写入套接字或套接字关闭,所以我认为这个数字与此无关(不像在c套接字中,我需要用未写入的字节重试写入) 我猜唯一可以返回的错误是由于套接字关闭导致写入失败 所有这些似乎都不在文档中,或者我找错了位置?这是基于setWriteDadline的超时。如果它超时并写入了一些字节,您就知道写入了多少字节 Writer是封装基本写入方法的接口 Write将len(p)字节从p写入底层数据流。信息技术 返回从p(0)写入的字节数。您可以随时读取

我猜int是写入的字节数

我认为函数会一直阻塞,直到缓冲区完全写入套接字或套接字关闭,所以我认为这个数字与此无关(不像在c套接字中,我需要用未写入的字节重试写入)

我猜唯一可以返回的错误是由于套接字关闭导致写入失败


所有这些似乎都不在文档中,或者我找错了位置?

这是基于setWriteDadline的超时。如果它超时并写入了一些字节,您就知道写入了多少字节

Writer是封装基本写入方法的接口

Write将len(p)字节从p写入底层数据流。信息技术
返回从p(0)写入的字节数。您可以随时读取源代码:@PaulHankin Lol,我阅读了函数的定义,并意识到我所问的细节直到更深入时才得到回答。
import "io" 
type Writer interface {
        Write(p []byte) (n int, err error)
}
type Conn interface {
        // Read reads data from the connection.
        // Read can be made to time out and return a Error with Timeout() == true
        // after a fixed time limit; see SetDeadline and SetReadDeadline.
        Read(b []byte) (n int, err error)

        // Write writes data to the connection.
        // Write can be made to time out and return a Error with Timeout() == true
        // after a fixed time limit; see SetDeadline and SetWriteDeadline.
        Write(b []byte) (n int, err error)

        // Close closes the connection.
        // Any blocked Read or Write operations will be unblocked and return errors.
        Close() error

        // LocalAddr returns the local network address.
        LocalAddr() Addr

        // RemoteAddr returns the remote network address.
        RemoteAddr() Addr

        // SetDeadline sets the read and write deadlines associated
        // with the connection. It is equivalent to calling both
        // SetReadDeadline and SetWriteDeadline.
        //
        // A deadline is an absolute time after which I/O operations
        // fail with a timeout (see type Error) instead of
        // blocking. The deadline applies to all future I/O, not just
        // the immediately following call to Read or Write.
        //
        // An idle timeout can be implemented by repeatedly extending
        // the deadline after successful Read or Write calls.
        //
        // A zero value for t means I/O operations will not time out.
        SetDeadline(t time.Time) error

        // SetReadDeadline sets the deadline for future Read calls.
        // A zero value for t means Read will not time out.
        SetReadDeadline(t time.Time) error

        // SetWriteDeadline sets the deadline for future Write calls.
        // Even if write times out, it may return n > 0, indicating that
        // some of the data was successfully written.
        // A zero value for t means Write will not time out.
        SetWriteDeadline(t time.Time) error
}
func (c *IPConn) Write(b []byte) (int, error)