clrghouz/app/Console/Commands/CommZmodemReceive.php

51 lines
1017 B
PHP
Raw Normal View History

2021-04-01 10:59:15 +00:00
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use App\Classes\Sock\SocketException;
use App\Classes\Sock\SocketServer;
use App\Classes\Protocol\Zmodem as ZmodemClass;
class CommZmodemReceive extends Command
2021-04-01 10:59:15 +00:00
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'comm:zmodem:receive';
2021-04-01 10:59:15 +00:00
/**
* The console command description.
*
* @var string
*/
protected $description = 'ZMODEM receive';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
Log::info('Listening for ZMODEM connections...');
$server = new SocketServer(60177,'0.0.0.0');
$server->setConnectionHandler([new ZmodemClass,'onConnect']);
try {
$server->listen();
} catch (SocketException $e) {
if ($e->getMessage() == 'Can\'t accept connections: "Success"')
Log::debug('Server Terminated');
else
Log::emergency('Uncaught Message: '.$e->getMessage());
}
}
}