Skip to content
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

proposal: x/net: internal/socket should be public #23367

Closed
anacrolix opened this issue Jan 8, 2018 · 8 comments
Closed

proposal: x/net: internal/socket should be public #23367

anacrolix opened this issue Jan 8, 2018 · 8 comments

Comments

@anacrolix
Copy link
Contributor

internal/socket allows wrapping existing net.Conn types to access additional system calls. Going via the ipv4/ipv6 route shouldn't be necessary.

I have a net.UDPConn, and want to get at recvmmsg on it.

@gopherbot gopherbot added this to the Unreleased milestone Jan 8, 2018
@bradfitz bradfitz changed the title x/net: internal/socket should be public proposal: x/net: internal/socket should be public Jan 8, 2018
@bradfitz
Copy link
Contributor

bradfitz commented Jan 8, 2018

/cc @mikioh

@rsc
Copy link
Contributor

rsc commented Jan 8, 2018

To access additional system calls, as of Go 1.9, net.Conns implement https://golang.org/pkg/syscall/#Conn, which lets you get a syscall.RawConn, which lets you use the fd directly. So maybe exposing internal/socket is not needed?

@anacrolix
Copy link
Contributor Author

Yes but internal/socket has exposes recvmmsg and recvmsg with a Go interface. syscall.RawConn requires that I do syscalls directly myself, which I'd like to avoid.

@bradfitz
Copy link
Contributor

bradfitz commented Jan 9, 2018

You can wrap it up into a nice Go package on GitHub, though, and then use that from your pretty code. internal/socket was never written for external consumption.

@anacrolix
Copy link
Contributor Author

Yes, I understand that. But I think internal/socket has been erroneously concealed from external use by assuming users go through the ipv4/ipv6 packages (unless I missed something). A Go wrapper to recvmsg and recvmmsg should be exposed somewhere, why not here, where the current API is precisely what is needed. If I copy this package to use it elsewhere, I'll risk drifting from the semi-official state of x/net, which evolves to fit the syscall story of the day.

Note there are other socket domains that support msg oriented syscalls, it seems like an appropriate abstraction to expose.

@as
Copy link
Contributor

as commented Jan 11, 2018

Was it not already exposed once when Berkely baked it into UNIX? How many generations will endure its abstract fragrance?

@rsc
Copy link
Contributor

rsc commented Jan 29, 2018

syscall.RawConn requires that I do syscalls directly myself, which I'd like to avoid.

It sounds like RawConn lets you do what you need. I understand you wish it was nicer, but we don't want to commit to any of the API in internal/socket.

@rsc rsc closed this as completed Jan 29, 2018
@mikioh
Copy link
Contributor

mikioh commented Jan 31, 2018

The same as #17930, I'm personally fine with having a UDP-specific package in x/net repository. Also fine with considering a comprehensive way; constructing a bit more modern transport layer API such as Post Sockets.

@golang golang locked and limited conversation to collaborators Jan 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants