Hi Ariel,
   Based on your suggestion below, I have implemented a Socket server in my 
external application dll , and now listen to it on a different port than the 
one that it connects with OOo.  I have been able to connect with it from the 
OOBasic macro function. I am even able to send across a string to the external 
application using the socket connection. However  I am facing some issues which 
I have posted on the openoffice forum. 
Could you please have a look and let me know if you have any suggestions to 
make it work.

http://forum.openoffice.org/en/forum/viewtopic.php?f=44&t=59806

Thanks
Mangesh


-----Original Message-----
From: Ariel Constenla-Haile [mailto:arie...@apache.org] 
Sent: Friday, February 15, 2013 7:25 PM
To: api@openoffice.apache.org
Subject: Re: communicating with a connected external application using OOBasic 
macro

Hi Mangesh Shukla,

On Fri, Feb 15, 2013 at 10:26:44AM +0000, Shukla, Mangesh wrote:
> Hi, I have  an external application which connects to OpenOffice.org 
> application using sockets. The connection string can be given as
> "uno:socket,host=localhost,port=2081 ". OpenOffice was started in 
> accept mode with the above string. I have an application level macro 
> which needs to call a function in the external application. I am 
> hoping to use the bridge connection using sockets to make this 
> communication work.

But you cannot use the same port, this port is reserved for OpenOffice, the 
application is already listening on that port.

If I understood, what you are doing is:

- OpenOffice is started in listening mode, it accepts connections from
  UNO bridges on port 2081

- you have an external application that interacts with OpenOffice; for
  this, instead of using the simple bootstrap mechanism, you create
  a UNO interprocess bridge using the connection URL
  "uno:socket,host=localhost,port=2081"

- inside OpenOffice you have a Basic macro, and you want this Basic
  macro to interact with the external application using a socket

Then, localhost:2081 is reserved for OpenOffice, listening in this port for UNO 
interprocess connection. OpenOffice is an css.connection.XAcceptor, the UNO 
bridge that uses your external application is a css.connection.XConnector.

If you want your Basic macro to communicate to the external application, the 
external application has to be listening on another port, different from 2081, 
and the Basic macro has to connect to it. You have:
OpenOffice listening in 2081, your application connects to OpenOffice in 2081, 
your application listens in NNNN, your macro connects to NNNN. You can do all 
this with the UNO API, or simplify it using your preferred language.

The external application has to implement a sort of server, listening for 
requests from your Basic macro. I doubt that implementing this in UNO API would 
be an easy task. If written in Python, the external application could use the 
powerful SocketServer module; the macro can be in Basic, connecting using UNO 
API; or make it simpler, write the macro in Python/Java and use Python/Java 
directly to communicate to your external application.


Regards
--
Ariel Constenla-Haile
La Plata, Argentina

Reply via email to