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

syscall.SetsockoptInt cannot work on Windows #3

Open
YoshieraHuang opened this issue Feb 9, 2020 · 2 comments
Open

syscall.SetsockoptInt cannot work on Windows #3

YoshieraHuang opened this issue Feb 9, 2020 · 2 comments

Comments

@YoshieraHuang
Copy link

When I build this project on Windows, this error appears:

cannot use int(file.Fd()) (type int) as type syscall.Handle in argument to syscall.GetsockoptInt

Google says that GetsockoptInt is a very Unix thing and not compatible with Windows. Codes for GetsockoptInt in golang for Windows is like this:

func GetsockoptInt(fd Handle, level, opt int) (int, error) { return -1, EWINDOWS }
@YoshieraHuang
Copy link
Author

syscall package for Windows define a new type syscall.Handle and it is an equivalence to uintptr. The first argument of GetsockoptInt and SetsocketoptInt functions is syscall.Handle in Windows, not uintptr in Linux.

@quentinmit
Copy link
Owner

Unfortunately I don't really have any good way to test this package on Windows; in that particular case, however, it looks like GetsockoptInt is now implemented in the golang.org/x/sys/windows package that replaced syscall. While Windows and Unix are often very different, Windows adopted the Unix socket API, so getsockopt does indeed exist on windows.

I think we'd need to take all the calls to GetsockoptInt and SetsockoptInt and put them into build tag-controlled files that import unix or windows as appropriate. I'm probably unlikely to do that myself but I'm happy to take a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants