Hi,
I declared the struct time value and import the header sys/time.h also.
but when compile the program it returns gives the error "/home/lsf/mesh_project/D5/src/lib/mcast.c|199|error: ‘timeval’ undeclared (first use in this function)|"
my program is written as follows.
Code:
#include "mcast.h"
#include "msgmcast.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/unistd.h>
// some methods which works fine
int recvfromTimeOut(int socket, long sec, long usec)
{
// Setup timeval variable
timeval timeout;
timeout.tv_sec = sec;
timeout.tv_usec = usec;
// Setup fd_set structure
fd_set fds;
FD_ZERO(&fds);
FD_SET(socket, &fds);
// Return value:
// -1: error occured
// 0: timed out
// >0: data ready to be read
return select(0, &fds, 0, 0, &timeout);
}
what goes wrong with this. apreciate you time regarding this.
thanks