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

net: enable File method on Windows #3827

Closed
anacrolix opened this issue Jul 15, 2012 · 7 comments

Comments

Projects
None yet
6 participants
@anacrolix
Copy link
Contributor

commented Jul 15, 2012

Please consider implementing dup for netFDs on Windows. Currently calling .File() on
users of this type returns the error "dup not implemented on Windows".

There's no equivalent to dup for sockets on Windows. DuplicateHandle doesn't work for
sockets, and WSADuplicateSocket has other purposes. I think it may be necessary to
implement an open/close ref count in addition to the completion port ref counting that's
currently used.

http://stackoverflow.com/questions/11319025/get-syscall-handle-from-a-go-net-udpconn-on-windows
@alexbrainman

This comment has been minimized.

Copy link
Member

commented Jul 24, 2012

Comment 1:

I think you are wrong about DuplicateHandle. It succeeds for a socket in a small program
I wrote.
But, I think, our argument is pointless. If you are reporting a bug, then, please,
provide a reproducible example. If you are asking for a new feature, then I am not clear
about what you are after.
If you want new SetTTL function in net, then
https://golang.org/issue/3826 should be enough. If you just must
have access to socket handle, then you should say so. I do not see what having
"implement dup for netFD on Windows" will do for you.
Alex

Status changed to WaitingForReply.

@kdar

This comment has been minimized.

Copy link

commented Jul 25, 2012

Comment 2:

I agree that having access to the socket handle would be nice. I really don't understand
what all this data hiding is about sometimes.
@alexbrainman

This comment has been minimized.

Copy link
Member

commented Jul 26, 2012

Comment 3:

Leaving for others to decide what to do. But given that we already expose
(*os.File).Fd(), perhaps, we could do the same for net sockets.
Alex

Status changed to New.

@anacrolix

This comment has been minimized.

Copy link
Contributor Author

commented Jul 26, 2012

Comment 4:

I provided some implementation details because I discovered it wasn't quite
straightforward. Naturally it should be decided by someone who submits a patch; they're
just notes.
The data hiding is a *real* PITA, especially as the language is new, many things are
hidden so that rewriting or patching entire core libraries is necessary to expose
things. That's a separate complaint.
It would be great if the socket handle was just exposed (and the dangers of abusing it
made clear in the documentation, naturally). I don't really want to duplicate it; my end
goal is to get at a `syscall.Handle` for the socket to set the TTL.
@bradfitz

This comment has been minimized.

Copy link
Member

commented Aug 7, 2012

Comment 5:

The data hiding is there so we can write portable APIs that are stable and maintainable
long-term.
It's easier to export stuff over time than hide stuff over time.
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Aug 11, 2012

Comment 6:

File method on Conn/PacketConn already exists on Unix variants.
I'm happy with this method, it would be help for fixing issue #3684.
Dear Mr. Brainman:
Do you have a time to review http://golang.org/cl/6445070/ ?
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Sep 6, 2012

Comment 7:

Status changed to Duplicate.

Merged into issue #3684.

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.