Click here to Skip to main content
15,889,868 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
My idea is to use select() to identify appended lines to the files.

Here is a very brief code:

int fd =open("c:\\1.log",O_RDONLY);

char buff[256];
fd_set rfdset;
FD_ZERO(&rfdset);
timeval tv;
tv.tv_sec = 30;
tv.tv_usec = 0;

FD_SET(fd, &rfdset);
while (1)
{
      int bReady = select(1,&rfdset,NULL,NULL,NULL);
      if (bReady > 0)
      {
    int n =  read(fd,buff,255);
    printf("\n %d : %s",n,buff);
      }else
          {
    printf("Select failed with Error : %ld",GetLastError());
            break;
          }
}

close(fd);


:( with this I am hitting the error:10038(An operation was attempted on something that is not a socket.)
Posted
Updated 11-May-10 1:42am
v4

From reading MSDN[^] I don't think select() on Windows supports file descriptors... only sockets.
This is unlike Linux[^] where select() works with files, pipes, sockets, etc...

Hope this helps! :)
 
Share this answer
 
v2
And which is the question? You should provide more specific informations about what are you trying to do, and what is your trouble; a code snippet will be helpful.
 
Share this answer
 
Comments
Vijay_Vijay 11-May-10 7:37am    
just added snippet, can you check now
Vijay_Vijay wrote:
with this I am hitting the error:10038(An operation was attempted on something that is not a socket.


Well, I don't think that could be much clearer. As I said in the other forum where you posted this query, select() is for network sockets not disk files.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900