Robert What platform are you using? Windows/Linux? What programming language are you using?
I would use IP addresses, not hostnames. If you use hostnames and somebody plugs a board into your network, how will the rest of your network be able to resolve the new hostname? Are you using some form of dynamic DNS? If you use an IP address, there is nothing to resolve as long as your new node has it's NIC(s) setup to 'play nice' with your network. Cheers Matt -----Original Message----- From: Robert Hegner [mailto:rheg...@hsr.ch] Sent: 04 August 2011 14:13 To: openslp-users@lists.sourceforge.net Subject: Re: [Openslp-users] How to register a service with the local IP address? Thanks for your answer! Before I write about what I came up with, here some background about my project: The goal is that the user can attach a node (an embedded computer which provides some service) to the network, and it should show up in some GUI application without the need to configure anything. So manually setting the IP address which should be published on every node separately is not an option. So here's my idea (the best so far...): I use boost.asio to get all local IP addresses, using the approach described here: http://hi.baidu.com/xshl5/blog/item/bebd0ee9df347f3ab80e2d8c.html This is still ugly because it needs to be able to resolve the hostname, but at least it should be portable. Now on my developer machine (with two network cards), I can find three IPv6 and two IPv4 addresses. So, as you wrote, the problem is to decide which address to use. I decided to register my service several times, with all available IP addresses. As URL-path I use an id which uniquely identifies a node. So the GUI will find several services with the same id and it can use ping to choose (the) one it can actually reach. This is not nice, but it's a beginning... But maybe I should really consider working with hostnames instead of IP addresses anyway. Then I would need to register the service only once (with one hostname instead of several IPs). I'll have to think about the consequences of this desicion for the rest of my project... With the above mentioned solution for finding my local IP addresses I need to make sure that every node has its own unique and valid hostname anyway. Maybe my nodes can give themselves an arbitrary, but globally unique ID (GUID) as a hostname when they boot for the first time? Then there is no need for the user to configure anything. Robert Am 04.08.2011 14:05, schrieb Philipp Schafft: > reflum, > > On Thu, 2011-08-04 at 09:29 +0200, Robert Hegner wrote: >> Using SLPReg I'd like to register >> >> service:TrackingNode.CP://192.168.0.100:1234 >> >> where the IP address should actually be the the local IP address of >> my NIC. This sounds to me like a common problem when using SLP, but I >> haven't found a solution yet. >> >> The problem is that I haven't found a nice and portable way to >> discover the local IP address (using gethostname and gethostbyname is >> ugly and Windows specific, for example). >> >> What is the common practice to register a service using the current >> IP address? > > This is a non-easy problem and I don't have a good solution for you. > > Yet there are some points you should consider: > A lot systems (even my laptop) has multiple externel addresses plus > loopback address. In addition there is no 'eth0' so requesting the > address of hardcoded 'eth0' will fail on some systems (eth0 broke and > I replaced the card. As it is a new card it got a new name.) > > looking up hostname (both gethostname() and uname()) works for me but > often people have use strange hostnames ('localhost'...) or hostnames > can not be resolved. > > There can also be some kind of address translation in between > (NAT,...) which requires you to publish a IP address not your real one. > > I think a good application should allow the user to give the address > in some kind of configuration file, dialog,... > > I also think that plublishing hostnames (not IP addresses) solves some > (most) of the abo´ve problems. This should be prefered. > > > If you find a good solution please tell me. ;) > > > > > > ---------------------------------------------------------------------- > -------- BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, > CA The must-attend event for mobile developers. Connect with experts. > Get tools for creating Super Apps. See the latest technologies. > Sessions, hands-on labs, demos& much more. Register early& save! > http://p.sf.net/sfu/rim-blackberry-1 > > > > _______________________________________________ > Openslp-users mailing list > Openslp-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openslp-users ---------------------------------------------------------------------------- -- BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA The must-attend event for mobile developers. Connect with experts. Get tools for creating Super Apps. See the latest technologies. Sessions, hands-on labs, demos & much more. Register early & save! http://p.sf.net/sfu/rim-blackberry-1 _______________________________________________ Openslp-users mailing list Openslp-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openslp-users This email, including any attachment, is a confidential communication intended solely for the use of the individual or entity to whom it is addressed. It contains information which is private and may be proprietary or covered by legal professional privilege. If you have received this email in error, please notify the sender upon receipt, and immediately delete it from your system. Anything contained in this email that is not connected with the businesses of this company is neither endorsed by nor is the liability of this company. Whilst we have taken reasonable precautions to ensure that any attachment to this email has been swept for viruses, we cannot accept liability for any damage sustained as a result of software viruses, and would advise that you carry out your own virus checks before opening any attachment. ------------------------------------------------------------------------------ BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA The must-attend event for mobile developers. Connect with experts. Get tools for creating Super Apps. See the latest technologies. Sessions, hands-on labs, demos & much more. Register early & save! http://p.sf.net/sfu/rim-blackberry-1 _______________________________________________ Openslp-users mailing list Openslp-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openslp-users