3 * A general listener class
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.ship-simu.org
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 class BaseListener extends BaseHubSystem {
26 * Address (IP mostly) we shall listen on
28 private $listenAddress = '0.0.0.0'; // This is the default and listens on all interfaces
31 * Port we shall listen on (or wait for incoming data)
33 private $listenPort = 0; // This port MUST be changed by your application
36 * Wether we are in blocking or non-blocking mode (default: non-blocking
38 private $blockingMode = false;
41 * Protected constructor
43 * @param $className Name of the class
46 protected function __construct ($className) {
47 // Call parent constructor
48 parent::__construct($className);
52 * Setter for listen address
54 * @param $listenAddress The address this listener should listen on
57 protected final function setListenAddress ($listenAddress) {
58 $this->listenAddress = (string) $listenAddress;
62 * Getter for listen address
64 * @return $listenAddress The address this listener should listen on
66 public final function getListenAddress () {
67 return $this->listenAddress;
71 * Setter for listen port
73 * @param $listenPort The port this listener should listen on
76 protected final function setListenPort ($listenPort) {
77 $this->listenPort = (int) $listenPort;
81 * Getter for listen port
83 * @return $listenPort The port this listener should listen on
85 public final function getListenPort () {
86 return $this->listenPort;
90 * "Setter" to set listen address from configuration entry
92 * @param $configEntry The configuration entry holding our listen address
95 public final function setListenAddressByConfiguration ($configEntry) {
96 $this->setListenAddress($this->getConfigInstance()->readConfig($configEntry));
100 * "Setter" to set listen port from configuration entry
102 * @param $configEntry The configuration entry holding our listen port
105 public final function setListenPortByConfiguration ($configEntry) {
106 $this->setListenPort($this->getConfigInstance()->readConfig($configEntry));