Sockets, multiple clients
I am trying to implement a channel, which receives packets from multiple clients.
I want to check the packets I get in a specific time interval each time (100 milliseconds).
If I get more than 1 packet, I need to send to all the clients an error packet, if I get
only 1 packet, I will forward it to the relevant server.
Any idea on how to implement that "receiving on time intervals"?
Re: Sockets, multiple clients
Depends how accurate it needs to be. You could sleep the process for 100ms, then do all the stuff on wakeup. Time per iteration will be 100ms plus processing time. So if it needs to be exactly 10 times a second, every second, best bet is to wakeup more frequently than that (say every 10ms) then check the system clock and see if it's 100ms later than the last time you did stuff: if not go back to sleep, if so then do the processing. You'll still get a bit of jitter this way but you can reduce the amount of jitter by reducing the sleep time. If it needs to be *exactly* every 100ms then you will need an RTOS.
|All times are GMT +5.5. The time now is 03:05.|