mdlayher / vsock

Package vsock provides access to Linux VM sockets (AF_VSOCK) for communication between a hypervisor and its virtual machines. MIT Licensed.
MIT License
328 stars 65 forks source link

Fd behind the Conn? #48

Closed paul-lalonde closed 2 years ago

paul-lalonde commented 2 years ago

Thanks for this great package - it does exactly what it says on the tin!

I need to pass the file descriptor to a vsock connection to a child process. Is there a straightforward way to get the fd (or an os.File) from the Conn retured from Accept?

I know my type, and am willing to type assert.

mdlayher commented 2 years ago

Yep, see: https://pkg.go.dev/github.com/mdlayher/vsock#Conn.SyscallConn

This will give you access to methods that expose the file descriptor. Closing!

paul-lalonde commented 2 years ago

Genius - thanks!