This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: fdopen() and winsock
- To: Bob Crispen <crispen@hiwaay.net>
- Subject: Re: fdopen() and winsock
- From: Mumit Khan <khan@xraylith.wisc.EDU>
- Date: Wed, 18 Aug 1999 23:06:48 -0500
- cc: cygwin@sourceware.cygnus.com
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