microsoft / go-winio

Win32 IO-related utilities for Go
MIT License
952 stars 182 forks source link

Added HV Socket known IDs, Dial, bug fixes #239

Closed helsaawy closed 2 years ago

helsaawy commented 2 years ago

Added:

Bug fixes:

Created a sockets package, currently only with syscalls to Bind, ConnectEx and GetSockName, bypassing syscall/windows restrictions on the types that cane be used

Signed-off-by: Hamza El-Saawy hamzaelsaawy@microsoft.com

kevpar commented 2 years ago

This seems like a change that should be split across multiple PRs. For instance can we add sockets package, and then use it in another PR?

I'd also like to understand better what the motivation is for these changes. What can a user of go-winio not do without these changes?

helsaawy commented 2 years ago

This seems like a change that should be split across multiple PRs. For instance can we add sockets package, and then use it in another PR?

I'd also like to understand better what the motivation is for these changes. What can a user of go-winio not do without these changes?

Without the sockets package, a user wouldn't be able to call GetPeerName, Bind, or ConnectEx on an arbitrary socket type (the syscall packages only allow them on types implemented internal to them). We had our own bind internally here, but it wasnt exported and required handling raw pointers.

Those three (GetPeerName, Bind, andConnectEx) are fairly useless on their own, but they allow use to easily define our own Dial for HV sockets.

I could add sockets alone, but I think it would look fairly unnecessary, as without Hvsock defining its own socket type, it would appear fairly redundant with golang's socket functions.

That said, I can split this into sockets and HV sockets updates (or HV sockets feature additions and bug fixes).