fdopen() and winsock

Mumit Khan khan@xraylith.wisc.EDU
Tue Aug 31 23:49:00 GMT 1999


Bob Crispen <crispen@hiwaay.net> writes:
> This has come up several times in the archives, but the only
> reply I've seen so far is "you can't do that" so I thought
> I'd try again, just in case.
> 
> When I compile with Cygwin 2.95 and don't set the -mno-cygwin
> flag, then the following works just fine:
> 
>     /*
>     * Convert the socket to a stream
>     */
>     if (0 > (sf = fdopen(s, "r+"))) {
> 	fprintf(stderr, "fdopen failed: %s\n", strerror(errno));
> 	close(s);
> 	exit (EXIT_FAILURE);
>     }
> 

Ah, as far as I know, one of the big limitations of winsock is that
the SOCKET type is *not* equivalent to file descriptor unlike that
using BSD or POSIX sockets. That's one of the major reasons for using
a separate data type, SOCKET, as opposed to int, typical type of a 
file descriptor. This implies that you cannot mix SOCKETs and stdio,
sorry. This is the case when you use -mno-cygwin.

Cygwin of course implements POSIX sockets and there is no problem
there. Case without -mno-cygwin.

Regards,
Mumit


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list