Created server:start, turned down BINKP debugging, some Socket tweaks
This commit is contained in:
@@ -276,7 +276,8 @@ final class Binkd extends BaseProtocol
|
||||
*/
|
||||
private function binkp_recv(): int
|
||||
{
|
||||
Log::debug(sprintf('%s: + Start',__METHOD__));
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: + Start',__METHOD__));
|
||||
|
||||
$buf = '';
|
||||
$blksz = $this->rx_size == -1 ? BinkpMessage::BLK_HDR_SIZE : $this->rx_size;
|
||||
@@ -288,7 +289,8 @@ final class Binkd extends BaseProtocol
|
||||
} catch (SocketException $e) {
|
||||
if ($e->getCode() == 11) {
|
||||
// @todo We maybe should count these and abort if there are too many?
|
||||
Log::debug(sprintf('%s: - Socket EAGAIN',__METHOD__));
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - Socket EAGAIN',__METHOD__));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -322,7 +324,8 @@ final class Binkd extends BaseProtocol
|
||||
$this->rx_size = ((ord(substr($buf,0,1))&0x7f) << 8 )+ord(substr($buf,1,1));
|
||||
$this->rx_ptr = 0;
|
||||
|
||||
Log::debug(sprintf('%s: - HEADER, is_msg [%d]',__METHOD__,$this->is_msg));
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - HEADER, is_msg [%d]',__METHOD__,$this->is_msg));
|
||||
|
||||
if ($this->rx_size == 0)
|
||||
goto ZeroLen;
|
||||
@@ -332,7 +335,8 @@ final class Binkd extends BaseProtocol
|
||||
/* Next block */
|
||||
} else {
|
||||
ZeroLen:
|
||||
Log::debug(sprintf('%s: - NEXT BLOCK, is_msg [%d]',__METHOD__,$this->is_msg));
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - NEXT BLOCK, is_msg [%d]',__METHOD__,$this->is_msg));
|
||||
|
||||
if ($this->is_msg) {
|
||||
$this->mib++;
|
||||
@@ -346,7 +350,8 @@ final class Binkd extends BaseProtocol
|
||||
return 1;
|
||||
}
|
||||
|
||||
Log::debug(sprintf('%s: - BUFFER [%d]',__METHOD__,strlen($buf)));
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - BUFFER [%d]',__METHOD__,strlen($buf)));
|
||||
|
||||
$rc = ord(substr($buf,0,1));
|
||||
|
||||
@@ -440,7 +445,9 @@ final class Binkd extends BaseProtocol
|
||||
$rc = 1;
|
||||
}
|
||||
|
||||
Log::debug(sprintf('%s: = End [%d]',__METHOD__,$rc));
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: = End [%d]',__METHOD__,$rc));
|
||||
|
||||
return $rc;
|
||||
}
|
||||
|
||||
@@ -449,12 +456,14 @@ final class Binkd extends BaseProtocol
|
||||
*/
|
||||
private function binkp_send(): int
|
||||
{
|
||||
Log::debug(sprintf('%s: + Start - tx_left [%d]',__METHOD__,$this->tx_left));
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: + Start - tx_left [%d]',__METHOD__,$this->tx_left));
|
||||
|
||||
if ($this->tx_left == 0 ) { /* tx buffer is empty */
|
||||
$this->tx_ptr = $this->tx_left = 0;
|
||||
|
||||
Log::debug(sprintf('%s: - Msgs [%d]',__METHOD__,$this->mqueue->count()));
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - Msgs [%d]',__METHOD__,$this->mqueue->count()));
|
||||
|
||||
if ($this->mqueue->count()) { /* there are unsent messages */
|
||||
while ($msg = $this->mqueue->shift()) {
|
||||
@@ -522,7 +531,9 @@ final class Binkd extends BaseProtocol
|
||||
}
|
||||
}
|
||||
|
||||
Log::debug(sprintf('%s: = End [1]',__METHOD__));
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: = End [1]',__METHOD__));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@@ -418,7 +418,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
Log::notice(sprintf('%s: - Remote Phone Number [%s]',__METHOD__,$this->emsi_dat_parse($str,$x,']')));
|
||||
|
||||
/* Baud rate */
|
||||
$this->client->setSpeed($this->emsi_dat_parse($str,$x,']'));
|
||||
$this->client->speed = $this->emsi_dat_parse($str,$x,']');
|
||||
|
||||
/* Flags */
|
||||
Log::notice(sprintf('%s: - Remote Flags [%s]',__METHOD__,$this->emsi_dat_parse($str,$x,']')));
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user