+ 1

Timer in c programming

Hi friends I wrote socket program to connect RPi and mobile. After connecting mobile with RPi through Bluetooth. It(RPi) is waiting to read data (called read function in program ) until it receives data from mobile. The requirement is to wait just for 60 sec. If this time exceeds read function has to stop and socket should re initiate. So how could I use the timer here and how could I terminate a read function. Please suggest me some solution Thank you

6th Aug 2019, 10:43 AM
malepu rakesh
malepu rakesh - avatar
1 Antwort
+ 2
You could use a thread that sleep for 60 seconds then send a signal to the main thread (via a flag for example) to tell that timeout is reached
7th Dec 2019, 2:01 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar