void CheckTasks()
{
makeTimer("First Timer", &firstTimerID, 2, 2); //2ms
makeTimer("Second Timer", &secondTimerID, 10, 10); //10ms
makeTimer("Third Timer", &thirdTimerID, 100, 100); //100ms
}
int CreateSocket()
{
socklen_t len;
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
// Socket creation for UDP
acceptSocket=socket(AF_INET,SOCK_DGRAM,0);
if(acceptSocket==-1)
{
printf("Failure: socket creation is failed, failure code\n");
return 1;
}
else
{
printf("Socket started!\n");
}
memset(&addr, 0, sizeof(addr));
addr.sin_family=AF_INET;
addr.sin_port=htons(port);
addr.sin_addr.s_addr=htonl(INADDR_ANY);
rc=bind(acceptSocket,(struct sockaddr*)&addr,sizeof(addr));
if(rc== -1)
{
printf("Oh dear, something went wrong with bind()! %s\n", strerror(errno));
return 1;
}
else
{
printf("Socket an port %d \n",port);
}
while(rc!=-1)
{
len = sizeof(client);
rc=recvfrom(acceptSocket,buf, 256, 0, (struct sockaddr*) &client, &len);
if(rc==0)
{
printf("Server has no connection..\n");
break;
}
if(rc==-1)
{
printf("Oh dear, something went wrong with read()! %s\n", strerror(errno));
break;
}
XcpIp_RxCallback( (uint16) rc, (uint8*) buf, (uint16) port );
sa.sa_handler = &CheckTasks;
sigaction(SIGUSR1, &sa, NULL);
}
close(acceptSocket);
return 0;
}
I created a socket to receive the data from the client and after receiving the data from client I should call the CheckTasks function, so I am using a signal handler to call this function but why isn't it coming out of the XcpIp_RxCallback( (uint16) rc, (uint8*) buf, (uint16) port ); ?? If i do like above for my situation - will it work ?? I have to call the CheckTasks function as soon as I receive the data from the client. I am receiving the data from the client. but I am failing to call the CheckTasks function to do further processing :( Could someone guide me in this ??