Update SocketClient to support UDP. Change DNS queries to use SocketClient

This commit is contained in:
2023-04-23 23:08:30 +10:00
parent 073be20ceb
commit b1c62ae227
5 changed files with 262 additions and 164 deletions

View File

@@ -138,14 +138,15 @@ final class SocketServer {
private function loop_udp()
{
$buf = '';
$remote = [];
$remote['ip'] = NULL;
$remote['port'] = NULL;
while (TRUE) {
if (socket_recvfrom($this->server,$buf,512,MSG_WAITALL,$remote['ip'],$remote['port']))
$this->handler[0]->{$this->handler[1]}($remote,$buf,$this->server);
$r = new SocketClient($this->server);
if ($r->hasData(30)) {
$this->handler[0]->{$this->handler[1]}($r);
// Sleep so our thread has a chance to pick up the data from our connection
usleep(50000);
}
}
}