65 lines
1.4 KiB
PHP
65 lines
1.4 KiB
PHP
<?php
|
|
|
|
/** DomFramework
|
|
* @package domframework
|
|
* @author Dominique Fournier <dominique@fournier38.fr>
|
|
* @license BSD
|
|
*/
|
|
|
|
namespace Domframework;
|
|
|
|
/**
|
|
* Manage the HTTP Connections.
|
|
* Used by HttpServer
|
|
*/
|
|
class HttpConnection
|
|
{
|
|
private $tcpserver;
|
|
private $clientAddress;
|
|
private $clientPort;
|
|
private $localAddress;
|
|
private $localPort;
|
|
private $logger;
|
|
|
|
public function __construct($tcpserver)
|
|
{
|
|
$this->tcpserver = $tcpserver;
|
|
list($clientAddress, $clientPort, $localAddress, $localPort) =
|
|
$tcpserver->getInfo();
|
|
// If the address is in IPv4 in IPv6 (syntax : "::ffff:127.0.0.1"),
|
|
// update it to IPv4 only
|
|
if (substr($clientAddress, 0, 7) === "::ffff:") {
|
|
$clientAddress = substr($clientAddress, 7);
|
|
}
|
|
$this->clientAddress = $clientAddress;
|
|
$this->clientPort = $clientPort;
|
|
$this->localAddress = $localAddress;
|
|
$this->localPort = $localPort;
|
|
echo "OK : $localAddress:$localPort";
|
|
}
|
|
|
|
public function __destruct()
|
|
{
|
|
}
|
|
|
|
public function getClientAddress()
|
|
{
|
|
return $this->clientAddress;
|
|
}
|
|
|
|
public function getClientPort()
|
|
{
|
|
return $this->clientPort;
|
|
}
|
|
|
|
public function getLocalAddress()
|
|
{
|
|
return $this->localAddress;
|
|
}
|
|
|
|
public function getLocalPort()
|
|
{
|
|
return $this->localPort;
|
|
}
|
|
}
|