I have a HANDLE like that:
HANDLE hPipe = CreateNamedPipe(...)
Is possible to convert the hPipe to a File Descriptor (int)?
I need this because I have implemented in C++ a code to work with TLS using the OpenSSL. This is working like a charm with TCP sockets, but I really need use it over Namedpipe.
The OpenSSL's function SSL_set_fd(SSL *ssl, int fd) accepts just FileDescriptor that is a int, and not a HANDLE.
Note: I also tried use the below function, but doesn't worked (return 3):
int fd = _open_osfhandle(reinterpret_cast<intptr_t>(hPipe), 0);
The 3
you're getting back isn't an error, it's the file descriptor handle. If you look at the documentation you'll see that it returns -1
for failure, otherwise the return value is a file descriptor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With