void ParallelComposer::open(void)
{
#ifdef OSG_WITH_PARALLEL
    if(getPcLibPath() != "")
    {
        pcSysInitialize(getPcLibPath().c_str(), 123458);
    }
    else
    {
        char *pc = getenv("PCLIB_PATH");
        if(pc!= NULL)
            pcSysInitialize(pc, 123458);
        else
            pcSysInitialize(".", 123458);
    }
    
    // Initialize buffers
    _bufColor	   = NULL;
    _bufDepth	   = NULL;
    _bufRet 	   = NULL;
    _createContext = true;
    
    // determine usable servers
    _usableServers = serverCount();

    // create server cross connection
    _clusterWindow->getNetwork()->connectAllPointToPoint(clusterId(),
                                                         "StreamSock");
    // do not buffer any data
    for(UInt32 i=0 ; i <= serverCount() ; ++i)
        clusterWindow()->getNetwork()->getConnection(i)->forceDirectIO();	
    // populate server list from inherited cluster window
    osgGetHostname(_serviceAddr, sizeof(_serviceAddr));

    _serverList = new char*[_usableServers+2];
    _serverList[0]  = _serviceAddr;
    int i = 1;
    for(; i<_usableServers+1; i++)
    {
        _serverList[i] = (char*)clusterWindow()->getServers(i-1).c_str();
    }
    _serverList[i]= NULL;
#endif
}
OSG_USING_NAMESPACE

/*! \class OSG::ClusterServer
    \brief Cluster rendering server

   A ClusterServer is responsible for syncronizing all client changes.
   Each cluster renderer can offer it's service by a symbolic name.
   So it is possible to have a server called "left" or "right".
   The server uses a local Qt or GLUT window for rendering.
   <pre>
   // create a server
   GLUTWindowPtr window=GLUTWindow::create();
   server = new ClusterServer(window,"server1","Multicast");
   // wait for clients to connect
   server->init();
   ...
   // render
   server->render(ract);
   </pre>
 */

/*-------------------------------------------------------------------------*/
/*                            Constructors                                 */

/*! Constructor
 *
 * \param window          rendering window. e.g. a Qt or GLUT window
 * \param serviceName     wait for connections that request this name
 * \param connectionType  network type. e.g. "Multicast"
 * \param address         address to wait for connections
 * \param servicePort     port to wait for connections
 * \param serviceGroup    service group
 *
 */
ClusterServer::ClusterServer(           Window *window,
                                        const std::string &serviceName,
                                        const std::string &connectionType,
                                        const std::string &address,
                                        UInt32  servicePort,
                                        const std::string &serviceGroup):
    _window(window),
    _connection(NULL),
    _requestAddress(address),
    _boundAddress(""),
    _clusterWindow(),
    _aspect(NULL),
    _serviceName(serviceName),
    _connectionType(connectionType),
    _servicePort(servicePort),
    _serviceGroup(serviceGroup),
    _serverId(0),
    _interface("")
{
    char localhost[256];

    // default is hostname
    if(_serviceName.empty())
    {
        osgGetHostname(localhost,255);
        _serviceName = localhost;
    }
    // if service contains ":" than treat as address
    if(_requestAddress.empty())
    {
        if(strstr(_serviceName.c_str(),":"))
            _requestAddress = _serviceName;
    }
}