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

Expose native file descriptor for handle like objects. #4720

Closed
p6rt opened this issue Nov 2, 2015 · 4 comments
Closed

Expose native file descriptor for handle like objects. #4720

p6rt opened this issue Nov 2, 2015 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Nov 2, 2015

Migrated from rt.perl.org#126541 (status was 'resolved')

Searchable as RT126541$

@p6rt
Copy link
Author

p6rt commented Nov 2, 2015

From @jonathanstowe

Hi,
In a number of places in the design documents it is suggested that certain functionality on files (e.g. fcntl, ioctl) or sockets (e.g. getsockname, setsockopt) should be provided by external modules via the NativeCall interface, however the majority of these C library functions require the native "file descriptor" as one of the arguments.

It would be useful to module authors if the OS platform (or runtime environment) idea of a "file descriptor" was available through some accessor on the IO​::Handle, IO​::Socket etc

Where libuv is being used then this is available through

  int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd)

If libuv is being bypassed for sync operations at some later point then the descriptor will be available directly.

My personal fear is that if this is not provided for the use in modules that require them then people will just bypass IO​::* altogether creating an interoperability nightmare.

Thanks.

@p6rt
Copy link
Author

p6rt commented Dec 14, 2015

From @jnthn

On Mon Nov 02 10​:54​:27 2015, jns+bc@​gellyfish.co.uk wrote​:

Hi,
In a number of places in the design documents it is suggested that
certain functionality on files (e.g. fcntl, ioctl) or sockets (e.g.
getsockname, setsockopt) should be provided by external modules via
the NativeCall interface, however the majority of these C library
functions require the native "file descriptor" as one of the
arguments.

It would be useful to module authors if the OS platform (or runtime
environment) idea of a "file descriptor" was available through some
accessor on the IO​::Handle, IO​::Socket etc

Where libuv is being used then this is available through

int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd)

If libuv is being bypassed for sync operations at some later point
then the descriptor will be available directly.

My personal fear is that if this is not provided for the use in
modules that require them then people will just bypass IO​::*
altogether creating an interoperability nightmare.

Agree, it's wise to provide a way to get it for such scenarios. Added a .native-descriptor on file handles and sockets now. As the name suggests, it's native, as in platform specific (so you can expect to get a HANDLE value on Windows, for example). Tests in S32-io/native-descriptor.t.

@p6rt
Copy link
Author

p6rt commented Dec 14, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Dec 14, 2015

@jnthn - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Dec 14, 2015
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

1 participant