Cygwin select + sockets from DLL
Cygnus - Admin
cygnus@ncohafmuta.com
Fri Nov 19 05:52:00 GMT 1999
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
More information about the Cygwin
mailing list