New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net: add Deadline, ReadBuffer, ReadDeadline, WriteBuffer, WriteDeadline getters #13196

Open
sparrc opened this Issue Nov 9, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@sparrc
Copy link

sparrc commented Nov 9, 2015

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.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

ianlancetaylor commented Nov 9, 2015

Is there any way we could implement these in golang.org/x/net instead?

@sparrc

This comment has been minimized.

Copy link

sparrc commented Nov 9, 2015

@ianlancetaylor Yes, fine with me

@rsc

This comment has been minimized.

Copy link
Contributor

rsc commented Dec 28, 2015

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.

@rsc rsc changed the title proposal: net: Implement Getter functions for net <IP/TCP/UDP/Unix>Conn objects x/net: add Deadline, ReadBuffer, ReadDeadline, WriteBuffer, WriteDeadline getters Dec 28, 2015

@rsc rsc added this to the Unreleased milestone Dec 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment