Php socket blocking mode problem

The

code is as follows. The server will return data several times within 3 seconds. I want the following loop to be terminated after more than 3 seconds. What should I do?

 while ($mes = socket_read($socket, 1024)) {
//xxxxx
}
Jun.25,2021

record a start time outside the loop, judge the running time within the loop, and break the loop when the condition is exceeded

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3782d-2c092.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3782d-2c092.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?