3 * A general listener class
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub 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 * Used protocol (Default: invalid, which is invalid...)
28 private $protcol = 'invalid';
31 * Address (IP mostly) we shall listen on
33 private $listenAddress = '0.0.0.0'; // This is the default and listens on all interfaces
36 * Port we shall listen on (or wait for incoming data)
38 private $listenPort = 0; // This port MUST be changed by your application
41 * Wether we are in blocking or non-blocking mode (default: non-blocking
43 private $blockingMode = false;
46 * Protected constructor
48 * @param $className Name of the class
51 protected function __construct ($className) {
52 // Call parent constructor
53 parent::__construct($className);
57 * Setter for listen address
59 * @param $listenAddress The address this listener should listen on
62 protected final function setListenAddress ($listenAddress) {
63 $this->listenAddress = (string) $listenAddress;
67 * Getter for listen address
69 * @return $listenAddress The address this listener should listen on
71 public final function getListenAddress () {
72 return $this->listenAddress;
76 * Setter for listen port
78 * @param $listenPort The port this listener should listen on
81 protected final function setListenPort ($listenPort) {
82 $this->listenPort = (int) $listenPort;
86 * Getter for listen port
88 * @return $listenPort The port this listener should listen on
90 public final function getListenPort () {
91 return $this->listenPort;
95 * "Setter" to set listen address from configuration entry
97 * @param $configEntry The configuration entry holding our listen address
100 public final function setListenAddressByConfiguration ($configEntry) {
101 $this->setListenAddress($this->getConfigInstance()->readConfig($configEntry));
105 * "Setter" to set listen port from configuration entry
107 * @param $configEntry The configuration entry holding our listen port
110 public final function setListenPortByConfiguration ($configEntry) {
111 $this->setListenPort($this->getConfigInstance()->readConfig($configEntry));
115 * Setter for protocol
117 * @param $protocol Used protocol
120 protected final function setProtocol ($protocol) {
121 $this->protocol = (string) $protocol;
125 * Getter for protocol
127 * @return $protocol Used protocol
129 public final function getProtocol () {
130 return $this->protocol;