[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
[no subject]
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/
- Follow-Ups:
- Re:
- From: Ch Rama Krishna Prasad