Problem seems to be in synchronization of the threads. Can you please answer my other thread in this forum "synchronizing two threads".
In this post I would like you to help me where I am taking out the smallest packet from the list. I need not to wait using sleep() or usleep() for the system clock time to reach the packet time stamp. Can you please tell me how is it possible that I'll read the smallest packet and send it only when the system clock time is reached. If I Search in the list with the smallest packet and in match case if I use the system clock time to check with the packet time stamp. How this can be good enough to do the task? Here is the code. Thanks for your replies.
while(scurr->next!=NULL) // checking for the entire list
// this if is finding the packet with smallest time stamp
if(snode->ts.tv_sec < scurr->ts.tv_sec && snode->ts.tv_usec < scurr->ts.tv_usec)
// this if is checking the smallest packet with the system clock time
if(curr_time.tv_sec >= snode->ts.tv_sec && curr_time.tv_usec >= snode->ts.tv_usec)
struct sockaddr_ll destAddr;
if(snode2->rFlag==0 && snode2->wFlag==1)
// here I am writing the data on the wire
printf("retVal is %d",retVal);
printf("sendto() error \n");
printf("SENDER 1 --- packet number is %d OF length %d Sent \n",snode2->pkt_id,retVal);
}while(snode->next != NULL);