Currently there are the following setter functions in the net package for the IPConn, TCPConn, UDPConn, and UnixConn objects:
SetDeadline(t time.Time) error
SetReadBuffer(bytes int) error
SetReadDeadline(t time.Time) error
SetWriteBuffer(bytes int) error
SetWriteDeadline(t time.Time) error
Under the covers, these all call the unix C setsockopt() function
Since setsockopt has a corresponding getsockopt function, I'm proposing that we add the corresponding Getter functions to the net package, looking something like this:
GetDeadline() (time.Time, error)
GetReadBuffer() (int, error)
GetReadDeadline() (time.Time, error)
GetWriteBuffer() (int, error)
GetWriteDeadline() (time.Time, error)
This shouldn't be too difficult to implement, since the generated zsyscall_*.go files already have the getsockopt function.
This could be useful for debugging and logging information, and for checking if the corresponding Set function needs to be called.
Comment From: ianlancetaylor
Is there any way we could implement these in golang.org/x/net instead?
Comment From: sparrc
@ianlancetaylor Yes, fine with me
Comment From: rsc
I don't think these are generally useful enough to be worth the complexity they would add to the API. "shouldn't be too difficult" and "could be useful" are a very low bar, much lower than what is required for addition to the standard library. If you'd like to add them to x/net/ipv4 and x/net/ipv6, I guess that's fine.