* Re: Returned mail: delivery problems encountered
[not found] <2004102722581901500p7n00e@A@000000000000@comcast.net>
@ 2004-10-28 3:34 ` Edward Parrilla
2004-10-28 5:42 ` Glynn Clements
2004-10-28 16:26 ` Jan-Benedict Glaw
0 siblings, 2 replies; 3+ messages in thread
From: Edward Parrilla @ 2004-10-28 3:34 UTC (permalink / raw)
To: linux prg
>
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Returned mail: delivery problems encountered
2004-10-28 3:34 ` Returned mail: delivery problems encountered Edward Parrilla
@ 2004-10-28 5:42 ` Glynn Clements
2004-10-28 16:26 ` Jan-Benedict Glaw
1 sibling, 0 replies; 3+ messages in thread
From: Glynn Clements @ 2004-10-28 5:42 UTC (permalink / raw)
To: Edward Parrilla; +Cc: linux prg
Edward Parrilla wrote:
> > I have the following:
> > FD_SET(msock, &afds);
> > nfds=getdtablesize();
> > msock=passiveTCP(service, 5); <--listening socket
You should initialise msock *before* you use it.
--
Glynn Clements <glynn@gclements.plus.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Returned mail: delivery problems encountered
2004-10-28 3:34 ` Returned mail: delivery problems encountered Edward Parrilla
2004-10-28 5:42 ` Glynn Clements
@ 2004-10-28 16:26 ` Jan-Benedict Glaw
1 sibling, 0 replies; 3+ messages in thread
From: Jan-Benedict Glaw @ 2004-10-28 16:26 UTC (permalink / raw)
To: linux prg
[-- Attachment #1: Type: text/plain, Size: 1711 bytes --]
On Wed, 2004-10-27 22:34:05 -0500, Edward Parrilla <eparrilla@comcast.net>
wrote in message <1098934436.6437.7.camel@localhost.localdomain>:
> > I have the following:
> > #define STDIN 0
Use STDIN_FILENO (unistd.h) instead of this hack.
> > /* .......*/
> >
> > 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.
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:-)
> > if (FD_ISSET(msock, &rfds))
> > {
> > handle _incoming _request()
> > }
> >
> > }
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +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));
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-10-28 16:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <2004102722581901500p7n00e@A@000000000000@comcast.net>
2004-10-28 3:34 ` Returned mail: delivery problems encountered Edward Parrilla
2004-10-28 5:42 ` Glynn Clements
2004-10-28 16:26 ` Jan-Benedict Glaw
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).