About endpoints use udp

areslpareslp Member pei luoOrganization: buaaProject: distribution service,streaming server
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

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    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.
  • areslpareslp Member pei luoOrganization: buaaProject: distribution service,streaming server
    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?
  • areslpareslp Member pei luoOrganization: buaaProject: distribution service,streaming server
    Ok, I got it...I must use uncheckedCast because my server only support udp connection.

    PrinterPrx printer = PrinterPrx::uncheckedCast(base);
Sign In or Register to comment.