Skip to contentSkip to conversation

Returned mail: delivery problems encountered

DISCUSSION Edward Parrilla 3 participants 3 messages Oct 28, 2004 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 2004102722581901500p7n00e@A@[email protected]

#1 lore raw
Quoted 41 lines

Hi all,
I have the following:
#define STDIN 0
/* .......*/

int nfds;
struct timeval tv;
fd_set rfds;
fd_set afds;
FD_ZERO(&afds);
tv.tv_sec=0;
tv.tv_usec=0
FD_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

#2 lore raw
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]>
#3 lore raw
In reply to Edward Parrilla

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_set rfds;
fd_set afds;
FD_ZERO(&afds);
tv.tv_sec=0;
tv.tv_usec=0
FD_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));