Home Help Center

Ip Addresses and basic conection questions

Hello, i'm very new to ICE an also to network applications, so i have a couple of questions and i hope you can help me (and maybe point me to the proper manual pages, since i haven't yet found the answer to these questions).

1) Ice::ObjectPrx base= ic->stringToProxy("SimplePrinter:default -p 10000");

What ip address is being addressed here? Is it only localhost port 10.000? How can i connect specifically to, say, 192.168.0.165???

I think "SimplePrinter" here is an abstraction for an endpoint (ip address?), is it right?

2) In the server, how can i get the ip address of the machine that is using a servant object?

3) I need to do a chat-like program that's going to work on a class C lan (PC addreses 192.168.0.x) How can i implement clients that auto-discover the servers on my lan?

(for example, on start-up clients offers me a list of servers that he found on the lan)

Thank you very much!

P.D.: signature added :)

Comments

  • beaglesbeagles Member Brent EaglesOrganization: Eagles Technologies IncProject: Asterisk SCF ✭✭✭
    Please fill out your signature with the information specified in our forum [thread=1697]support policy[/thread].

    Cheers
  • EmmanuelOgaEmmanuelOga Member
    Signature addition done! :)
  • beaglesbeagles Member Brent EaglesOrganization: Eagles Technologies IncProject: Asterisk SCF ✭✭✭
    1) Ice::ObjectPrx base= ic->stringToProxy("SimplePrinter:default -p 10000");

    What ip address is being addressed here? Is it only localhost port 10.000? How can i connect specifically to, say, 192.168.0.165???

    I think "SimplePrinter" here is an abstraction for an endpoint (ip address?), is it right?

    "SimplePrinter" is the Ice object identity. "default" indicates that the 'default' protocol should be used. The host address can be specified using the -h option. e.g.:

    "SimplePrinter:default -h 192.168.0.165 -p 10000"

    would means something like "create a proxy for an object whose identity is 'SimplePrinter' which can be communicated with via the host with the IP address 192.168.0.165 using port 10000 and the default protocol for the communicator 'ic'".

    The Ice documentation describes Ice proxies in detail (including this specific example). I recommend giving it a good read. It will give you a huge head start in getting your project off the ground.

    2) In the server, how can i get the ip address of the machine that is using a servant object?

    Check out the Ice documentation on the Ice::Current object. It has a Ice::Connection member named 'con' that can be used to get this sort of information. You might also want to do a search on this in these forums to find discussions related to this topic.

    3) I need to do a chat-like program that's going to work on a class C lan (PC addreses 192.168.0.x) How can i implement clients that auto-discover the servers on my lan?

    True "Auto-discovery" of services isn't available. Check out [thread=2425]this thread[/thread] for some relevant discussion.

    Cheers
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Emmanuel,
    1) Ice::ObjectPrx base= ic->stringToProxy("SimplePrinter:default -p 10000");

    What ip address is being addressed here? Is it only localhost port 10.000? How can i connect specifically to, say, 192.168.0.165???

    When you omit the host name/IP from a TCP/SSL/UDP endpoint, you get the IP address corresponding to the hostname as returned by gethostname(). See Appendix D.2 in the Ice manual.

    In order to get the desired host/IP address, just use -h, e.g.:
    "SimplePrinter:default -h 192.168.0.165 -p 10000"
    I think "SimplePrinter" here is an abstraction for an endpoint (ip address?), is it right?
    Not, it's the identity of the target object. The endpoint is the information after the ':'.
    2) In the server, how can i get the ip address of the machine that is using a servant object?

    Ice does not provide such an API; however your OS probably does. If you don't specific an address or hostname when you create an Ice object adapter, this object adapter will listen on all interfaces on the host computer. See appendix D.2 for full details.
    3) I need to do a chat-like program that's going to work on a class C lan (PC addreses 192.168.0.x) How can i implement clients that auto-discover the servers on my lan?
    (for example, on start-up clients offers me a list of servers that he found on the lan)

    The simplest solution would be to run IceGrid in a well-know location (host, port) and register an object in each of your chat servers as "well-known" with IceGrid. Then your clients can retrieve the list of chat servers by querying the IceGrid registry.

    Cheers,
    Bernard
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    bernard wrote:
    When you omit the host name/IP from a TCP/SSL/UDP endpoint, you get the IP address corresponding to the hostname as returned by gethostname(). See Appendix D.2 in the Ice manual.

    It turns out this changed between Ice 3.0.1 and Ice 3.1, and the manual was not updated :(.

    The "Clients semantics" are now similar to the "server semantics", i.e. if you omit -h, your stringified proxy expands to a proxy with an endpoint for each local interface except loopback--except when loopback is the only interface.

    This will be fixed in the next revision on the manual.

    Cheers,
    Bernard
Sign In or Register to comment.