Created server:start, turned down BINKP debugging, some Socket tweaks

This commit is contained in:
Deon George
2021-06-16 22:26:08 +10:00
parent 292040cef7
commit f9310566a0
4 changed files with 133 additions and 33 deletions

View File

@@ -188,6 +188,7 @@ final class SocketClient {
if ($this->DEBUG)
Log::debug(sprintf('%s: = End [%d]',__METHOD__,$rc));
return $rc;
}
@@ -298,6 +299,10 @@ final class SocketClient {
if ($rc === FALSE)
throw new SocketException($x=socket_last_error($this->connection),socket_strerror($x));
// If our buffer is null, see if we have any out of band data.
if (($rc == 0) && is_nulL($buf) && ($this->hasData(0) > 0))
socket_recv($this->connection,$buf, $len,MSG_OOB);
return is_null($buf) ? '' : $buf;
}
@@ -319,7 +324,8 @@ final class SocketClient {
if ($this->hasData($timeout) > 0) {
try {
if (! strlen($this->rx_buf = $this->read(0,self::RX_BUF_SIZE))) {
Log::debug(sprintf('%s: - Nothing read',__METHOD__));
if ($this->DEBUG)
Log::debug(sprintf('%s: - Nothing read',__METHOD__));
return self::TTY_TIMEOUT;
}
@@ -376,17 +382,6 @@ final class SocketClient {
return socket_write($this->connection,$message,$length);
}
/**
* Set our speed
*
* @param int $value
* @todo change to __set()
*/
public function setSpeed(int $value): void
{
$this->speed = $value;
}
/**
* Wait for data on a socket
*
@@ -404,18 +399,10 @@ final class SocketClient {
if ($rc === FALSE)
throw new \Exception('Socket Error: '.socket_strerror(socket_last_error()));
return $rc;
}
if ($this->DEBUG)
Log::debug(sprintf('Socket select returned [%d] (%d)',$rc,$timeout),['read'=>$read,'write'=>$write,'except'=>$except]);
/**
* Return our speed in bps
*
* @return int
* @todo change to __get()
*/
public function speed(): int
{
return $this->speed;
return $rc;
}
public function timer_expired(int $timer): int