Archived

This forum has been archived. Please start a new discussion on GitHub.

ICE-E in MFC connection refused

I´m working with Ice-E to build a PocketPC server using VS 2005.

I create the server as usual:

Ice::CommunicatorPtr communicator;
Ice::ObjectAdapterPtr adapter;
try
{
int argc = 0;
Ice::PropertiesPtr properties = Ice::createProperties();
properties->setProperty("CClie.Endpoints", "tcp -p 20000");
communicator = Ice::initializeWithProperties(argc, 0, properties);
adapter = communicator->createObjectAdapter("CClie");
Ice::ObjectPtr servant = new clienteI(dlg.getVideoDlg());
adapter->add(servant, Ice::stringToIdentity("cclie"));
adapter->activate();
}
catch(const Ice::Exception& ex)
{
AfxMessageBox(CString(ex.toString().c_str()), MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}

But, when I try to access from client I've got a WSACONNECTIONREFUSED exception.

I have a Win32 version of this server and it works fine so the client-side code it´s ok.

Comments

  • matthew
    matthew NL, Canada
    You should enable network tracing in your server & client to find out what endpoints you are listening on in the server, and what endpoints your client is attempting to connect with. Please see the Ice manual for details on how to do this.
  • marc
    marc Florida
    Have a look at this FAQ.
  • Everything it's ok but it doesn´t work.

    I´m using Virtual Machine Network Services with Microsoft Device Emulator. Is there any incompatibility or something?

    This is the client-side code:

    int argc = 0;
    Ice::InitializationData initData;
    std::string prx, propname, proxyprop;
    Cliente::CCliePrx proxy;
    Ice::CommunicatorPtr communicator;
    Ice::ObjectPrx obj;

    prx = "cclie:tcp -p 20000 -h 192.168.2.67"
    initData.properties = Ice::createProperties();
    initData.properties->setProperty("CClie.Proxy",prx);
    communicator = Ice::initialize(argc, 0, initData);

    propname = "CClie.Proxy";
    proxyprop = communicator->getProperties()->getProperty(propname);
    obj = communicator->stringToProxy(proxyprop);
    proxy = Cliente::CCliePrx::checkedCast(obj);

    proxy->camDeleted(index);

    communicator->destroy();

    Thanks for your help!!!
  • marc
    marc Florida
    Please set the properties Ice.Trace.Network=3 and Ice.Trace.Protocol=1 for both the client and the server, and post both logs here. Without the logs, it's impossible to tell what's going on.
  • Ok, I've added a logger to each part.

    Client log (Win32):

    [ Network: trying to establish tcp connection to 192.168.2.67:20000 ]
    [ Network: trying to establish tcp connection to 192.168.2.67:20000 ]

    Server log (PocketPC) seems to fail:

    trace

    Maybe I'm doing something wrong initializing the communicator :confused:

    Thanks for your help!!!!

    P.D: I´m using the LogI class provided in the Ice-E demos
  • matthew
    matthew NL, Canada
    There are a number of things you can check. Firstly, you can use a debugger to ensure that the various log methods are being called (although it seems likely this is the case given the above debugger window).

    The LogI class posts WM_USER messages to the handle provided in setHandle. Did you call this method? And are you handling the WM_USER message?
  • You were right wise people!!! :D

    This is the server log:

    "[ Network: attempting to bind to tcp socket 127.0.0.1:20000 ]"
    "[ Network: accepting tcp connections at 127.0.0.1:20000 ]"

    So I have changed this:

    properties->setProperty("CClie.Endpoints", "tcp -p 20000");

    properties->setProperty("CClie.Endpoints", "tcp -p 20000 -h 192.168.2.67");

    As the first way takes loopback IP to accept requests.

    Now it works fine but I´m confused about this because I've always done like

    X.Endpoints=tcp -p portnumber

    Is it necessary to especify the host in Ice-E? I don´t think so...

    Anyway, thank you very much for your support and excuse me for bothering you with this.