Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Datasocket server not found problem

Hello all,
I've one datasocket problem I've been trying to solve.   On the datasocket server pc (192.168.0.100) , I publish about 20 data items ( dstp://localhost/wave1, dstp://localhost/wave2, etc.). I've 5 other pcs on the same network that want to view these data with only 5 items per pc. So I wrote a client program that will dynamically search for the datasocket server using the SelectURL method so I can select the items I want to view on that pc.  Here is a snippet of that program:


class CDataSocketClient : public CDialog
{
   private:
       CNiDataSocket m_DataSocket;
       .....
};

void CDataSocketClient::ClickBtn1()
{
       // sometimes work, but most of the time can't find the server!
    
      CString URL;
       URL = m_EditBox.GetWindowText();     // obtain the server ip address here eg., 192.168.0.100
       if ( m_DataSocketClient.SelectURL(URL, "Select  a data item") )
        {
             m_DataSocket.Connect(m_DataSocket.URL, CNiDataSocket::ReadAutoUpdate);
             ....
          }
}

The user should be able to pickup the items from the dialog box when the client found the server.  However, 9 of 10 times the dialog box would indicate that there is no data items available by a red X mark under the server ip address. I've made sure that the URL contain the valid address of the server ( "dstp://192.168.0.100" )when calling SelectURL.   But if I had hardcoded the URL by doing this:

void CDataSocketClient::ClickBtn1()
{
      CString URL;
       //URL = m_EditBox.GetWindowText();     // obtain the server ip address here eg., 192.168.0.100
       //if ( m_DataSocketClient.SelectURL(URL, "Select  a data item") )
        //{
          //   m_DataSocket.Connect(m_DataSocket.URL, CNiDataSocket::ReadAutoUpdate);
           //  ....
//          }
          // Always work!
          m_DataSocket.Connect("dstp://192.168.0.100/wave3", CNiDataSocket::ReadAutoUpdate);
          .....
}
   


0 Kudos
Message 1 of 1
(3,236 Views)