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

x/net/nettest: add TestListener API #31036

Open
mdlayher opened this issue Mar 25, 2019 · 6 comments

Comments

@mdlayher
Copy link
Member

commented Mar 25, 2019

I'm currently implementing my own net.Listener (see also #30984 and #31033), https://godoc.org/github.com/mdlayher/vsock#Listener, and would like to ensure it is in full compliance with the net.Listener contract; that is:

  • Accept blocks until a connection is receive, or it is interrupted
  • Close terminates the listener, but can also unblock Accept
  • Maybe: test for SetDeadline method (which is common for net.Listener, see #6892) and verify that an expired deadline unblocks Accept as well (this idea is in line with what I propose with #31033)

I've played around with this a bit locally to try to see what makes sense, and I will send a draft CL with my proposed API and a single test. The basic idea is to mirror what TestConn is doing, and perhaps the two can share a fair bit of internal code.

/cc @dsnet @mikioh @acln0

@gopherbot gopherbot added this to the Proposal milestone Mar 25, 2019
@gopherbot gopherbot added the Proposal label Mar 25, 2019
@gopherbot

This comment has been minimized.

Copy link

commented Mar 25, 2019

Change https://golang.org/cl/169177 mentions this issue: nettest: draft implementation of TestListener APIs

@mikioh

This comment has been minimized.

Copy link
Contributor

commented Mar 25, 2019

@mdlayher

This comment has been minimized.

Copy link
Member Author

commented Mar 25, 2019

I had no idea this was already in progress. I'll take a look tomorrow.

@mikioh

This comment has been minimized.

Copy link
Contributor

commented Mar 25, 2019

I still need to process long-standing CLs and that's one of them, sorry for my laziness. Basically, making x/net/nettest useful sounds nice because we are entering the modular era; vendoring x/net/nettest could deduplicate the test harnesses in the package net of the standard library.

@mdlayher

This comment has been minimized.

Copy link
Member Author

commented Mar 25, 2019

Happy to help with that effort.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2019

This seems fine to add to x/net/nettest. Will leave to @mikoh and @mdlayher to work out the review of CL 123056. Thanks!

@rsc rsc changed the title proposal: x/net/nettest: add TestListener API x/net/nettest: add TestListener API Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.