Using custom Winsock socket functions with Cygwin

Bruce Cran bruce@cran.org.uk
Tue Jun 1 19:06:00 GMT 2010


I have a Winsock provider DLL which communicates with a kernel SCTP
stack. I'd like to enable applications built with both Visual Studio and
Cygwin to run because there's lots of code that's been ported from
Linux. However, the problem I've come across is that because I have a
few custom socket functions such as sctp_sendmsg and sctp_recvmsg that
don't go through the Winsock layer but still get a SOCKET
descriptor, I get passed Cygwin's internal file descriptor - i.e. I can
see my WSPAccept function returns a value of 161 up the stack but it
gets translated to 4 by Cygwin's socket code, and the 161 value will be
stored in the io_handle member of the fhandler_socket class. I thought
I could maybe use GetFileType and _get_osfhandle to deal with running
under Cygwin but it turns out that GetFileType tells me I have a valid
handle, and converting it using _get_osfhandle anyway gives me an
invalid handle back.

Is there some way to detect that the handle's wrong and fetch the
proper one without my code needing detailed knowledge of the
fhandler_socket class?

-- 
Bruce Cran

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list