Home Help Center

Printer Tutorial Runtime Error

MrfredMrfred Member Ryan FredericksOrganization: PersonalProject: Middleware Comparison for Future Development
Hello all!

I'm trying to learn Ice and went through the manual and tried the first example. It builds properly and everything; however, when I run the server, all that happens is it prints "TcpEndpointI.cpp" and then exits. The client does the same except the message is "Network.cpp"

I have no idea why this happens, as I have read over the manual and much information online. I am fairly certain that the line that my server has an issue with is the following
Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p10000");

I am using Microsoft Visual Studio Express 2012 for Windows Desktop which uses Visual C++ 2012. I am compiling it under Release and it appears to build fine without any errors. Please let me know if you have any suggestions as to what could be wrong with my setup.

Thanks a lot.
Mrfred

EDIT: For those of you who don't know the code included in the manual, here it is:
#include <Ice/Ice.h>
#include <Printer.h>
using namespace std;
using namespace Demo;

class PrinterI : public Printer {
public:
	virtual void printString(const string& s, const Ice::Current&);
};

void PrinterI::printString(const string& s, const Ice::Current&) {
	cout << s << endl;
}

int main(int argc, char* argv[]) {
	int status = 0;
	Ice::CommunicatorPtr ic;
	try {
		ic = Ice::initialize(argc, argv);
		Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p10000");
		Ice::ObjectPtr object = new PrinterI;
		adapter->add(object, ic->stringToIdentity("SimplePrinter"));
		adapter->activate();
		ic->waitForShutdown();
	} catch (const Ice::Exception& e) {
		cerr << e << endl;
		cout << "ice exception" << endl;
		status = 1;
	} catch (const char* msg) {
		cerr << msg << endl;
		status = 1;
	}
	if (ic) {
		try {
			ic->destroy();
		} catch (const Ice::Exception& e) {
			cerr << e << endl;
			status = 1;
		}
	}
	return status;
}

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi,

    Welcome to the forum.

    If the code you pasted is exactly what you're using, there's a space missing from your object adapter endpoint. It should be "default -p 10000". What puzzles me more is why you don't get more informative output when displaying the exception.

    Regards,
    Mark
  • MrfredMrfred Member Ryan FredericksOrganization: PersonalProject: Middleware Comparison for Future Development
    Wow, thanks. I feel dumb. That space got me up to this line:
    adapter->add(object, ic->stringToIdentity("SimplePrinter"));
    

    where it exited with message "Instance.cpp"

    I am new to Ice, but I believe all that line is doing is telling the adapter that a new servant is there called "SimplePrinter". I'm pretty sure I'm not missing a space in this one, but any help is greatly appriciated, and thanks a lot for your reply Mark.
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    I suggest rebuilding in debug mode. Note that you'll also need to change the libraries that you link with to use the debug versions.

    If you're still having trouble, create an archive of your VS project and attach it here.

    Mark
Sign In or Register to comment.