Hi Anandh,

On Tue, Feb 26, 2013 at 10:58:43AM +0530, Anandha Kannan wrote:
> Hi,
> 
>      I have an issue in resolving UNO URL after launching open office from
> my applicaiton developing in Mac.
> I start open office using socket as
> "-accept=socket,host=localhost,port=2081;urp;"
> 
> This starts OO. Now to open a file passed from my application, I have the
> following code,
> 
> rConnectionString = OUString::createFromAscii(
> "uno:socket,host=localhost,port=2081;urp;StarOffice.ServiceManager");
 

The connection URLs look fine (hint: use StarOffice.ComponentContext to
get the component context directly, no need to go through the service
manager.

And you'll find more useful a connection aware client, instead of using
the com.sun.star.bridge.UnoUrlResolver, see
http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Example:_A_Connection_Aware_Client

Quoting from
http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Importing_a_UNO_Object

The usage of the UnoUrlResolver has certain disadvantages. You cannot:

- be notified when the bridge terminates for whatever reasons
- close the underlying interprocess connection
- offer a local object as an initial object to the remote process 

I've just uploaded an example (compiled only on Linux, later I'll test
it on Win and MacOS too):
http://svn.apache.org/viewvc/openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/ConnectionAwareClient/

> Here, I get exception saying *Connector: couldn't connect to socket
> (Undefined error: 0). *What is the wrong with the UNO URL that causes this.
 
Do you try this code right after launching OpenOffice? May be the
application didn't start listening at that moment, you may have to wait
and give the application a little time to perform the start up actions.


> PS: After launching OOo, Using PortScan utility I can confirm that the port
> has been opened.

You can test with telnet:

telnet localhost 2081

You will get a request from the bridge counterpart (in URP protocol).
Also try with 

netstat -ntlp | grep soffice


Look at the example I quoted above, at the beginning it has
a std::cin.get() in order to wait for the application to start, I'm sure
that if you remove this, the example will fail because the office
started quickly but isn't listening yet. This might be your problem too;
of course, in a real application you don't put cin.get()'s ;) you'll
need a better solution (the C++ binding provides multiplatform
facilities - osl::Condition, osl::Thread, etc.).


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina

Attachment: pgpFMGX90kMwZ.pgp
Description: PGP signature

Reply via email to