Skip to content

net: add support for FileConn, FilePacketConn, FileListener on windows #9503

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

Closed
mattn opened this issue Jan 5, 2015 · 4 comments
Closed
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. FixPending Issues that have a fix which has not yet been reviewed or submitted. help wanted OS-Windows
Milestone

Comments

@mattn
Copy link
Member

mattn commented Jan 5, 2015

Issue for discussion.

FileListener is useful to implement graceful-restart server. ex: https://github.com/lestrrat/go-server-starter

I know windows doesn't have a way to pass FDs to external process like UNIX OSs.
But it's not impossible. WSADuplicateSocket can export intormation of file descriptor as WSAPROTOCOL_INFO to specified process. This structure is possible to be written to a file as byte array.

http://msdn.microsoft.com/ja-jp/library/windows/desktop/ms741565(v=vs.85).aspx

How about implementation of os.File.dup, os.FileListener on windows?

https://codereview.appspot.com/177590043/

@minux minux changed the title FileListener on windows net: FileListener on windows Jan 5, 2015
@mikioh mikioh changed the title net: FileListener on windows net: add support for FileConn, FilePacketConn, FileListener on windows Jan 5, 2015
@rsc rsc removed the os-windows label Apr 10, 2015
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc added the OS-Windows label Apr 15, 2015
@gopherbot
Copy link
Contributor

CL https://golang.org/cl/8683 mentions this issue.

@mikioh
Copy link
Contributor

mikioh commented Dec 28, 2018

This issue might be unfixable because of the architectural differences between Unix-variants and Windows. One good news is that Go 1.12 supports #24331; you may use os.File.SyscallConn instead of net.File{Conn,PacketConn,Listener} functions.

@evanmoses-okta
Copy link

@mikioh I've been trying to wrap a net.Listener around the syscall.Handle I get from windows sockets APIs (e.g. WSASocket). SyscallConn doesn't really help me with that...does it? I'd love to be able to do something like this:

	pi := syscall.WSAProtocolInfo{}
        //fill pi by some means
	fd, err := xwin.WSASocket(pi.AddressFamily, pi.SocketType, pi.Protocol, &pi, 0, 0)
	if err != nil {
		return nil, err
	}
        listener, err := net.FileListener(os.NewFile(uintptr(fd), "listener"))

But of course this doesn't work because of this issue.

@seankhliao seankhliao added the FeatureRequest Issues asking for a new feature that does not need a proposal. label Jul 13, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/668195 mentions this issue: net,os: support converting between *os.File and net.Conn on Windows

@dmitshur dmitshur added the FixPending Issues that have a fix which has not yet been reviewed or submitted. label May 1, 2025
@dmitshur dmitshur modified the milestones: Unplanned, Go1.25 May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. FixPending Issues that have a fix which has not yet been reviewed or submitted. help wanted OS-Windows
Projects
None yet
Development

No branches or pull requests

8 participants