This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Cygwin select + sockets from DLL


On Fri, 19 Nov 1999, Earnie Boyd wrote:
> 
> Well, unless the third party software uses cygwin1.dll (which I doubt), then
> based up the quoted comments you can't use the Cygwin select.  You must use the
> Windows sockets.h header and function set.
> 

are you serious? i can't use select() if i'm not gonna use the windows
header files?

I just started using the new cygwin to try and compile (under windows) a
unix-based chat server that I write. So far i've had numerous problems.

First, if i fork() the process twice to disassociate from the controlling
tty, windows gives me an illegal operation on startup. If I only fork()
once it goes by and forks, but as soon as it hits the select() in my
while() loop it stops and doesn't return. The program doesn't take
connections at all (connection refused)
If I DONT fork() the process to the background, the program works pretty
much fine, accept()'s multiple connections, etc..

Any help on this would be appreciated. Also looking for someone interested
in helping port this for windows use too..but that's another subject.

Here's a sample of my while loop..
        FD_ZERO(&readmask);
        FD_ZERO(&writemask);
        for (user = 0; user < MAX_USERS; ++user)
          {
            if (ustr[user].sock != -1) {
             FD_SET(ustr[user].sock,&readmask);
             if (ustr[user].output_size)
             FD_SET(ustr[user].sock,&writemask);
            }
          }
       for (i=0;i<4;++i) {
        /* Add the listening sockets to the read mask set */
        FD_SET(listen_sock[i],&readmask);
        }

#if defined(WIN32) && !defined(__CYGWIN32__)
        if (select(FD_SETSIZE, &readmask, &writemask, 0, 0) == SOCKET_ERROR) {
#else
        if (select(FD_SETSIZE, (void *) &readmask, (void *) &writemask,
(void *) 0, 0) == -1) {
#endif
         if (errno != EINTR) {
                sprintf(mess,"Select failed with error 
		(%d:%s)\n",errno,strerror(errno));
                print_to_syslog(mess);
                shutdown_error(log_error(9));
           }
         else continue;
        }


-Cygnus
.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-.
Anthony J. Biacco                       Network Administrator/Engineer
cygnus@ncohafmuta.com                    Intergrafix Internet Services

    "Dream as if you'll live forever, live as if you'll die today"
http://cygnus.ncohafmuta.com                http://www.intergrafix.net
.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-.



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]