Archived

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

About endpoints use udp

I tried the sample code in the Ice-3.3.0.pdf book, and it works fine.
I want to Ice use udp protocol to transfer, so I changed the server code to:
Ice::ObjectAdapterPtr adapter
= ic->createObjectAdapterWithEndpoints(
"SimplePrinterAdapter", "udp -p 10000");

changed the client code to:
Ice::ObjectPrx base = ic->stringToProxy(
"SimplePrinter:udp -p 10000");

But it gave me a Ice::NoEndpointException error.
Could someone tell me where I was doing wrong?Thanks a lot!

Comments

  • benoit
    benoit Rennes, France
    Hi,

    You need to change the proxy mode to "datagram" to be able to use UDP endpoints, for example:
    Ice::ObjectPrx base = ic->stringToProxy("SimplePrinter:udp -p 10000");
    base = base->ice_datagram();
    

    Cheers,
    Benoit.
  • Hi, benoit:

    I add base = base->ice_datagram(); but it throw another exception:
    Ice::TwowayOnlyException

    slice file:
    module Demo {
    	interface Printer {
    		void printString(string s);
    	};
    };
    

    I dont have out parameters, and I dont throw a exception ,why I got this error?
  • Ok, I got it...I must use uncheckedCast because my server only support udp connection.

    PrinterPrx printer = PrinterPrx::uncheckedCast(base);