processClock and Socket

Making & changing box plugins and external apps
Post Reply
matthieuG
Posts: 54
Joined: Thu Nov 12, 2009 10:22 am
Location: grenoble

processClock and Socket

Post by matthieuG »

I am observing the works of socket with openViBE and I wonder about the method processClock.

In fact, When only one try of connection is done, all seems to be Ok :

Code: Select all

//creation du "socket"
if(!m_pConnectionClient)
                {
                 m_pConnectionClient=Socket::createConnectionClient();
                 //connection à un serveur
                 m_pConnectionClient->connect(l_sServerName, l_ui32ServerPort);
                 if(!m_pConnectionClient->isConnected())
                        {
                         this->getLogManager() << LogLevel_ImportantWarning << "Could not connect to server " << l_sServerName << ":" << l_ui32ServerPort << "\n";
                         return false;
                        }
                }
However, if I propose to connect each time in processClock, I notice the message which inform of lost of real-time :

Code: Select all

   //creation du "socket"
        if(!m_pConnectionClient)
                {m_pConnectionClient=Socket::createConnectionClient();}
    //connection à un serveur
        if(m_pConnectionClient && !m_pConnectionClient->isConnected())
                {
                 m_pConnectionClient->connect(l_sServerName, l_ui32ServerPort);
                 if(!m_pConnectionClient->isConnected())
                        {
                         this->getLogManager() << LogLevel_ImportantWarning << "Could not connect to server " << l_sServerName << ":" << l_ui32ServerPort << "\n";
                         return true;
                        }
                }
Is due only that a connection take too much time? How works processClock() in relation to process()?

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: processClock and Socket

Post by yrenard »

Dear matthieuG,

I assume you are trying to implement a custom box algorithm which uses a TCP socket connection to whatever third party software you like.

As you should know, TCP connection is a connected mode, order is kept and there's no packet loss. The TCP connection establishment can take from several milliseconds to several seconds to be initialized depending on the quality of the connection and on different timeout parameters you may configure. However, this connection establishment is only performed at the begining. As soon as it is established, a path is drawn among the nodes of the network and the communication can be pretty fast.

So concerning your code, I can't see a big difference between the two code snippets you sent. However as I understand your problem, it sounds like the second proposition causes multiple connections to be requested. Either this is normal (e.g. the server is not responding, is it even started ?) or it is not (you request much more connections than necessary), I can't tell based on the sample code you sent.

Now for the processClock function, in OpenViBE, each box can be notified of three kinds of events : messages (forget this one, it is not used for now), clock (regular notification depending on the getClockFrequency function) and input arrival. In any of those three kinds of callback, the box should examine its internal state and declare if it's ready to process something (this is done calling the makrAlgorithmAsReadyToProcess function). As soon as the box is box algorithm is marked as ready to send, the kernel calls its process function.

I hope this is more clear.
Yann

Post Reply