Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 09-13-2006
nyingchi nyingchi is offline
Registered User
 
 
Join Date: Aug 2006
Posts: 13
how to know which port the adapter is using?

if i create a adapter using below statement:

Ice::ObjectAdapterPtr adapter= ic->createObjectAdapterWithEndpoints("sp", "tcp");

because the port is not specified, it will be selected by the operating system.

but now i want to know which port the opeating system selected for the adapter?

thanks for your reply.
__________________
kin Young

university: Sun Yat-sen University

url: http://www.sysu.edu.cn
learning ICE.
Reply With Quote
  #2 (permalink)  
Old 09-14-2006
benoit's Avatar
benoit benoit is offline
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,564
Hi,

There's no way to get this information directly. You can however create a proxy with the adapter and get the port number from the stringified proxy, for example:

Code:
   // C++
   Ice::ObjectAdapterPtr adapter  = communicator->createObjectAdapterWithEndpoints("MyAdapter", "tcp");
   cout << adapter->createProxy(communicator->stringToIdentity("Dummy"))->ice_toString() << endl;
You can also enable network tracing with --Ice.Trace.Network=1 to see on which port the object adapter is listening.

Cheers,
Benoit.
Reply With Quote
  #3 (permalink)  
Old 07-04-2008
kundertk kundertk is offline
Registered User
 
Name: Kris Kundert
Organization: Enbridge Pipelines Inc.
Project: IPC replacement
 
Join Date: Jun 2008
Posts: 3
Is this still the most current information for this particular problem?

We have a situation where we require running more than one server on a machine, each running as different users. So a statically defined port won't work for us. Being able to figure out what port was selected automatically without having to do some crazy regex on a string would be greatly beneficial.

Last edited by kundertk : 07-04-2008 at 11:48 AM. Reason: Adding more context..
Reply With Quote
  #4 (permalink)  
Old 07-07-2008
matthew's Avatar
matthew matthew is online now
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,088
Sorry, other than the technique recommended by Benoit (parsing strings), there is no way to retrieve this information.

An alternative to parsing the stringified form of the proxy is to call ice_getEndpoints() on the proxy, which returns a sequence of Endpoints. Then on each endpoint call toString() which, for a tcp endpoints, would return something like "tcp -h ... -p ...". This might be marginally easier to parse.

Out of curiosity, why do you need this information?
Reply With Quote
  #5 (permalink)  
Old 07-07-2008
kundertk kundertk is offline
Registered User
 
Name: Kris Kundert
Organization: Enbridge Pipelines Inc.
Project: IPC replacement
 
Join Date: Jun 2008
Posts: 3
Basically, we have an application that spawns child processes, and we want the child to be able to communicate with the parent process bi-directionally via Ice. To initiate the communication the child needs to know what port to connect to on the parent. The parent port isn't known ahead of time because there could be N copies of it running on a particular host, any of them as a different user. So the parent needs to pass the port as a parameter to the child.
Reply With Quote
  #6 (permalink)  
Old 07-07-2008
mes's Avatar
mes mes is online now
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 976
Hi Kris,

Instead of passing only the port to the child process, have you considered passing a stringified proxy?

Regards,
Mark
Reply With Quote
  #7 (permalink)  
Old 07-07-2008
kundertk kundertk is offline
Registered User
 
Name: Kris Kundert
Organization: Enbridge Pipelines Inc.
Project: IPC replacement
 
Join Date: Jun 2008
Posts: 3
No I haven't. Now that I think of it, I think that would completely solve my problem. I'm so used to thinking in terms of hosts and ports I never even considered just passing around a stringified proxy.

Thanks for the tip!
Reply With Quote
  #8 (permalink)  
Old 07-07-2008
mes's Avatar
mes mes is online now
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 976
There are a couple of things you should keep in mind if you decide to pass a stringified proxy to a child process. First of all, the string will contain spaces, so you may need to enclose it in quotes depending on how you are spawning the child. Second, the stringified proxy itself may contain quotes if the proxy's identity name or category has spaces. Of course, you only need to worry about the second issue if it's possible for your identities to contain spaces.

Take care,
Mark
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
QNX port n2503v Help Center 5 12-18-2006 06:16 PM
how to bind 0.0.0.0:port ? ewiniar Help Center 3 06-22-2006 10:15 PM
why not and when does ICE port to Symbian OS? genelee Comments 4 12-08-2005 04:42 PM
OpenBSD Port of Ice? msw10100 Help Center 0 07-30-2005 03:48 PM
AIX Port ScottDiedrick Help Center 1 04-13-2004 05:37 PM


All times are GMT -4. The time now is 12:12 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.