$socketFile = self::createTempPathForFile($listenerInstance->getConfigInstance()->getConfigEntry('ipc_socket_file_name'));
// Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: socketFile=' . $socketFile . ' ...');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: socketFile=' . $socketFile . ' ...');
// File name must not be empty
assert(!empty($socketFile));
$socketResource = socket_create(AF_UNIX, SOCK_STREAM, 0);
// Get container from it
- // @TODO Somehow handle $infoInstance to this factory
- $socketInstance = self::createObjectByConfiguredName('socket_container_class', array($socketResource, StorableSocket::SOCKET_PROTOCOL_FILE, $packageData, NULL));
+ $socketInstance = self::createObjectByConfiguredName('socket_container_class', array($socketResource, StorableSocket::SOCKET_PROTOCOL_FILE, $packageData));
// Debug message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FILE_LISTENER: socketInstance[]=%s', gettype($socketInstance)));
// Is the file there?
if ((FrameworkBootstrap::isReachableFilePath($packageData[StorableSocket::SOCKET_ARRAY_INDEX_FILE])) && (file_exists($packageData[StorableSocket::SOCKET_ARRAY_INDEX_FILE]))) {
// Old socket found
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: WARNING: Old socket at ' . $packageData[StorableSocket::SOCKET_ARRAY_INDEX_FILE] . ' found. Will not start.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: WARNING: Old socket at ' . $packageData[StorableSocket::SOCKET_ARRAY_INDEX_FILE] . ' found. Will not start.');
// Shutdown this socket
$socketInstance->shutdownSocket();
} // END - if
// Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Binding to ' . $packageData[StorableSocket::SOCKET_ARRAY_INDEX_FILE] . ' ...');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Binding to ' . $packageData[StorableSocket::SOCKET_ARRAY_INDEX_FILE] . ' ...');
// Try to bind to it
if (!$socketInstance->bindSocketTo($packageData[StorableSocket::SOCKET_ARRAY_INDEX_FILE])) {
} // END - if
// Start listen for connections
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Listening for connections.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Listening for connections.');
if (!$socketInstance->listenOnSocket()) {
// Handle this socket error with a faked recipientData array
$socketInstance->handleSocketError(__METHOD__, __LINE__, array_values($packageData));
} // END - if
// Allow non-blocking I/O
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Setting non-blocking mode.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Setting non-blocking mode.');
if (!$socketInstance->enableSocketNonBlocking()) {
// Handle this socket error with a faked recipientData array
$socketInstance->handleSocketError(__METHOD__, __LINE__, array_values($packageData));
//*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Created socket ' . $socketResource . '(' . gettype($socketResource) . ') from class ' . $className . '.');
// Construct container class, this won't be reached if an exception is thrown
- // @TODO Somehow handle $infoInstance to this factory
- $socketInstance = ObjectFactory::createObjectByConfiguredName('socket_container_class', array($socketResource, StorableSocket::SOCKET_PROTOCOL_TCP, $packageData, NULL));
+ $socketInstance = ObjectFactory::createObjectByConfiguredName('socket_container_class', array($socketResource, StorableSocket::SOCKET_PROTOCOL_TCP, $packageData));
// Is the socket resource valid?
if (!$socketInstance->isValidSocket()) {
} // END - if
// Set the option to reuse the port
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Enabling re-use address ...');
if (!$socketInstance->enableSocketReuseAddress()) {
// Handle this socket error with a faked recipientData array
$socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0'));
* it. This is now the default behaviour for all connection helpers who
* call initConnection(); .
*/
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Setting non-blocking mode.');
if (!$socketInstance->enableSocketNonBlocking()) {
// Handle this socket error with a faked recipientData array
$socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0'));
// Create a streaming socket, of type TCP/IP
$socketResource = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
- // @TODO Init fake package data with address/port from listener
+ // Init fake package data with address/port from listener
$packageData = array(
+ StorableSocket::SOCKET_ARRAY_INDEX_ADDRESS => $listenerInstance->getListenAddress(),
+ StorableSocket::SOCKET_ARRAY_INDEX_PORT => $listenerInstance->getListenPort(),
);
// Create socket instance
// Set the option to reuse the port
// @TODO: , SOL_SOCKET, SO_REUSEADDR, 1
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Enabling re-use address ...');
if (!$socketInstance->enableSocketReuseAddress()) {
// Handle this socket error with a faked recipientData array
$socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0'));
* that all connections on this port are now our resposibility to
* send/recv data, disconnect, etc..
*/
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-LISTENER: Binding to address ' . $listenerInstance->getListenAddress() . ':' . $listenerInstance->getListenPort());
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Binding to address ' . $listenerInstance->getListenAddress() . ':' . $listenerInstance->getListenPort());
if (!$socketInstance->bindSocketTo($listenerInstance->getListenAddress(), $listenerInstance->getListenPort())) {
// Handle this socket error with a faked recipientData array
$socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0'));
} // END - if
// Start listen for connections
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-LISTENER: Listening for connections.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Listening for connections.');
if (!$socketInstance->listenToSocket()) {
// Handle this socket error with a faked recipientData array
$socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0'));
} // END - if
// Now, we want non-blocking mode
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-LISTENER: Setting non-blocking mode.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Setting non-blocking mode.');
if (!$socketInstance->enableSocketNonBlocking()) {
// Handle this socket error with a faked recipientData array
$socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0'));