Returned mail: delivery problems encountered
Quoted 41 lines
Hi all,
I have the following:
#define STDIN 0
/* .......*/int nfds;
struct timeval tv;fd_setrfds;fd_setafds;FD_ZERO(&afds);
tv.tv_sec=0;
tv.tv_usec=0FD_SET(STDIN, &afds);FD_SET(msock, &afds);
nfds=getdtablesize();
msock=passiveTCP(service, 5); <--listening socket
while(1){ memcpy(&rfds,&afds, sizeof(rfds)); if (select(nfds, &rfds, (fd_set *)0, (fd_set *)0, &tv)<0) errexit (" error "); if (FD_ISSET(STDIN,&rfds) handle(stdin);/* it is not making to this line */ <-- here is the prolem, it does not make to the next line, it does work to the line before(i.e. takes input from STDIN), but it doesn't take something coming to the socket.
if (
FD_ISSET(msock, &rfds))
{
handle_incoming_request()
}}
Any idea why it couldn't be taking the incoming calls for the socket. Thanks in advance
Ed
Quoted 5 lines · Edward Parrilla
Quoted 5 lines
I have the following:
FD_SET(msock, &afds);
nfds=getdtablesize();
msock=passiveTCP(service, 5); <--listening socket
You should initialise msock *before* you use it.
Signature · 1 line
Glynn Clements <[email protected]>
On Wed, 2004-10-27 22:34:05 -0500, Edward Parrilla <[email protected]> wrote in message <[email protected]>:
Quoted 2 lines
Quoted 2 lines
I have the following:
#define STDIN 0
Use STDIN_FILENO (unistd.h) instead of this hack.
Quoted 22 lines
Quoted 22 lines
/* .......*/
int nfds;
struct timeval tv;fd_setrfds;fd_setafds;FD_ZERO(&afds);
tv.tv_sec=0;
tv.tv_usec=0FD_SET(STDIN, &afds);FD_SET(msock, &afds);
nfds=getdtablesize();
msock=passiveTCP(service, 5); <--listening socket
while(1){ memcpy(&rfds,&afds, sizeof(rfds)); if (select(nfds, &rfds, (fd_set *)0, (fd_set *)0, &tv)<0) errexit (" error "); if (FD_ISSET(STDIN,&rfds) handle(stdin);
Quoted 3 lines
Quoted 3 lines
/* it is not making to this line */ <-- here is the prolem, it does not make to the next line, it does work to the line before(i.e. takes input from STDIN), but it doesn't take something coming to the socket.
Glynn already pointed out that you FD_SET(msock) before you assign it. Additionally, you're calling select() inside a loop. You actually need to initialize tv.tv_sec, tv.tv_usec and afds _each time_ before calling select(). So move that into the loop:-)
Quoted 6 lines
Quoted 6 lines
if (
FD_ISSET(msock, &rfds))
{
handle_incoming_request()
}}
MfG, JBG
Signature · 4 lines
Jan-Benedict Glaw [email protected] . +49-172-7608481 _ O _ "Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));