[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re:



Hi Gopinath,
    Try this one statements

   struct pollfd     CbQPollFd[POLL_MAX_FD];

   /****** For Read Events *************/
    CbQPollFd[ii].fd = lpSeudoDesc;
      CbQPollFd[ii].events = 0 | POLLIN | POLLRDNORM;
      CbQPollFd[ii].revents = 0;
       ii++;
   /******* For Write Events *************/

            CbQPollFd[ii].fd = lpSocketDesc;
             CbQPollFd[ii].events =  0 | POLLOUT | POLLWRNORM;
            CbQPollFd[ii].revents = 0;
            ii++;
      ulRt_Value = poll(CbQPollFd,ii,20000);
      if (ulRt_Value < 0) {
        perror("poll");
        exit(1);        
         for(jj = 1; jj < ii; jj++)
         {
           if(CbQPollFd[jj].revents)
           then check for each socket if the revents is etted to any read or
write evnts.
Just i given some code you will expand it . It will work with this changes.

From
Ch.Rama krishna Prasad
          






On Tue, 13 Feb 2001, lakshmi gopinath wrote:
> Hi,
> 
> Thanks for helping me out. I am yet to use poll. But I
> am still having
> problem with select. In the following code both the
> FD_ISSET macro is
> returning 1 for both the calls to select even before
> data has arrived on
> them ! So the recvfrom calls are proceeding
> sequentially and until data
> arrives in the recvfrom call it is blocking.
> 
> for(;;)
>     {
>       FD_SET(sockfd1,&set);
>       FD_SET(sockfd2,&set);
>       maxfd1 = max(sockfd1,sockfd2) + 1;
>       select(maxfd1,&set,&set,NULL,&time);
>       printf("\n sokcfd1 status =
> %d",FD_ISSET(sockfd1,&set);
>       printf("\n sokcfd 2 status =
> %d",FD_ISSET(sockfd2,&set);
> 
>       if(status = FD_ISSET(sockfd1,&set))
>        {
>          bzero(buff1,sizeof(buff1));
>         count = recvfrom(sockfd1,(char
> *)buff1,sizeof(buff1),0,(struct
> sockaddr *)&client,&addrlen);
>          printf("\n %s",buff1);
>        }
> 
>          if(status = FD_ISSET(sockfd2,&set))
>         {
>          bzero(buff2,sizeof(buff2));
>         count = recvfrom(sockfd2,(char
> *)buff2,sizeof(buff2),0, (struct
> sockaddr *)&client,&addrlen);
>          printf("\n %s ",buff2);
>          }
>      }
> }
> 
> So i decided to make the recvfrom call non-blocking by
> using the flag
> MSG_DONTWAIT flag option. and i changed the code for
> both the sockets as
> follows :
> 
> count = recvfrom(sockfd2,(char
> *)buff2,sizeof(buff2),MSG_DONTWAIT, (struct
> sockaddr *)&client,&addrlen);
>  if(errno != EWOULDBLCOK)
>          printf("\n %s ",buff2);
> 
> 
> but in this case both the sockets are not accepting
> data from their
> respective buffers. I am still not able to identiful
> the problem. Could you
> please help me out. I am refering Unix Network
> Programming by Richard
> Stevens, edition 2.
> 
> Regards,
> Lakshmi
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail - only $35 
> a year!  http://personal.mail.yahoo.com/
> 
> ---------------------------------------------
> LIP is all for free speech.  But it was created
> for a purpose.  Violations of the rules of
> this list will result in stern action.