Ok, here it is:
Code:
void DUAL_Select(AUTH_IFE_STR *pAuth_Ife_Str)
{
fd_set readset;
int select_result,result;
int named_pipe;
int maxSOCK;
char *envPATH;
char nnamedPIPE[256];
char buffer[8];
named_pipe = open(nnamedPIPE, O_RDONLY | O_NONBLOCK);
pAuth_Ife_Str->sread_named_pipe=named_pipe;
FD_ZERO(&readset);
FD_CLR(pAuth_Ife_Str->sread_named_pipe,&readset);
FD_CLR(pAuth_Ife_Str->sSocketfd,&readset);
FD_SET(pAuth_Ife_Str->sread_named_pipe,&readset);
FD_SET(pAuth_Ife_Str->sSocketfd,&readset);
if ((pAuth_Ife_Str->sSocketfd - pAuth_Ife_Str->sread_named_pipe) > 0)
{
maxSOCK = pAuth_Ife_Str->sSocketfd;
}
else
{
maxSOCK = pAuth_Ife_Str->sread_named_pipe;
}
select_result = select(maxSOCK + 1, &readset, NULL, NULL, NULL);
if (FD_ISSET(pAuth_Ife_Str->sread_named_pipe, &readset))
{
FD_CLR(pAuth_Ife_Str->sread_named_pipe, &readset);
bzero(buffer,8);
result = read(pAuth_Ife_Str->sread_named_pipe,buffer,8);
if (FD_ISSET(pAuth_Ife_Str->sSocketfd, &readset))
{
FD_CLR(pAuth_Ife_Str->sSocketfd, &readset);
//printf("Socket is ready for read\n");
pAuth_Ife_Str->sSockReadAve = '1';
};
result = close (pAuth_Ife_Str->sread_named_pipe);
When closing the socket each time, it does seem to be fine, but that is what I am having to do. Is that correct?
What should I do when opening the npipe for write, open it in blocking or non-blocking mode?