-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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/sys/windows: fix Accept implementation #54212
Comments
Windows programs mostly use func Accept(fd Handle) (nfd Handle, sa Sockaddr, err error) |
@ianlancetaylor the problem is that in Winsock supports a classic I would recommend to implement |
For Unix, Accept shows up next to Sockaddr in pkg.go.dev because it is a constructor, not a method. The Accept signature in x/sys/windows can't be changed, but it would be fine to implement. Do I have that right? |
This proposal has been added to the active column of the proposals project |
@rsc I'm not really sure that it's possible to implement That means that SOCKET WSAAPI accept(
[in] SOCKET s,
[out] sockaddr *addr,
[in, out] int *addrlen
); There also an AcceptEx function but it's much more complicated and non POSIX-compatible. Do you know why it was initially designed with only 1 argument? And how it was supposed to be used? Thank you. |
The Windows |
@ianlancetaylor thank you for clarification :) |
One quick clarification, the addrlen is an [in, out] parameter, which means that it receives a value and based on that value it will refresh the value on the same memory address. I don't have experience with Accept specifically, but in some cases it's mandatory to pass the value into the syscall, and used the refreshed one. One specific example: WSALookupServiceNext also accepts a This doesn't mean that you need to update the function signature, but something to keep in mind. |
@rsc can I contribute somehow to the implementation if this proposal will be accepted? |
@x1unix Sure. Thanks. |
It sounds like everyone agrees this is about implementing a stub function, keeping the API exactly the same. Assuming that's true, there's no need for a proposal. |
Removing from the proposal process now that the issue is simply to implement the existing stub API with no API signature changes or new APIs. |
Removed from the proposal process. |
Currently
windows.Accept
(likesyscall.Accept
forGOOS=windows
) contains a stub function which does nothing.Looks like this function was introduced to mimic
unix.Sockaddr.Accept
method but it's just a useless stub.I propose to fix it's signature and re-implement it as winsock's accept function.
In the end it will look something like this:
Winsock accept function signature (see MSDN)
Instead of passing sockaddr raw pointer and it's size it's possible to also use
Sockaddr
interface and the same approach like inwindows.Bind
but it will limit method's potential use cases (it can't be used for custom sockets). See #54209.The text was updated successfully, but these errors were encountered: