Difference between revisions of "Documentation/DevGuide/ProUNO/Opening a Connection"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (1 revision(s))
 
(5 intermediate revisions by 3 users not shown)
Line 6: Line 6:
 
|NextPage=Documentation/DevGuide/ProUNO/Creating the Bridge
 
|NextPage=Documentation/DevGuide/ProUNO/Creating the Bridge
 
}}
 
}}
 +
{{Documentation/DevGuideLanguages|Documentation/DevGuide/ProUNO/{{SUBPAGENAME}}}}
 
{{DISPLAYTITLE:Opening a Connection}}
 
{{DISPLAYTITLE:Opening a Connection}}
 
The method to import a UNO object using the <code>UnoUrlResolver</code> has drawbacks as described in the previous chapter. The layer below the <code>UnoUrlResolver</code> offers full flexibility in interprocess connection handling.
 
The method to import a UNO object using the <code>UnoUrlResolver</code> has drawbacks as described in the previous chapter. The layer below the <code>UnoUrlResolver</code> offers full flexibility in interprocess connection handling.
Line 11: Line 12:
 
<!--<idltopic>com.sun.star.connection.Acceptor;com.sun.star.connection.Connector;com.sun.star.connection.XAcceptor;com.sun.star.connection.XConnector;com.sun.star.bridge.BridgeFactory;com.sun.star.bridge.XBridgeFactory</idltopic>-->
 
<!--<idltopic>com.sun.star.connection.Acceptor;com.sun.star.connection.Connector;com.sun.star.connection.XAcceptor;com.sun.star.connection.XConnector;com.sun.star.bridge.BridgeFactory;com.sun.star.bridge.XBridgeFactory</idltopic>-->
 
UNO interprocess bridges are established on the <idl>com.sun.star.connection.XConnection</idl> interface, which encapsulates a reliable bidirectional byte stream connection (such as a TCP/IP connection).  
 
UNO interprocess bridges are established on the <idl>com.sun.star.connection.XConnection</idl> interface, which encapsulates a reliable bidirectional byte stream connection (such as a TCP/IP connection).  
 
+
  <source lang="idl">
 
   interface XConnection: com::sun::star::uno::XInterface
 
   interface XConnection: com::sun::star::uno::XInterface
 
   {  
 
   {  
Line 22: Line 23:
 
       string getDescription();  
 
       string getDescription();  
 
   };
 
   };
 
+
  </source>
 
There are different mechanisms to establish an interprocess connection. Most of these mechanisms follow a similar pattern. One process listens on a resource and waits for one or more processes to connect to this resource.
 
There are different mechanisms to establish an interprocess connection. Most of these mechanisms follow a similar pattern. One process listens on a resource and waits for one or more processes to connect to this resource.
  
 
This pattern has been abstracted by the services <idl>com.sun.star.connection.Acceptor</idl> that exports the <idl>com.sun.star.connection.XAcceptor</idl> interface and <idl>com.sun.star.connection.Connector</idl> that exports the <idl>com.sun.star.connection.XConnector</idl> interface.
 
This pattern has been abstracted by the services <idl>com.sun.star.connection.Acceptor</idl> that exports the <idl>com.sun.star.connection.XAcceptor</idl> interface and <idl>com.sun.star.connection.Connector</idl> that exports the <idl>com.sun.star.connection.XConnector</idl> interface.
 
+
  <source lang="idl">
 
   interface XAcceptor: com::sun::star::uno::XInterface
 
   interface XAcceptor: com::sun::star::uno::XInterface
 
   {  
 
   {  
Line 42: Line 43:
 
           raises( NoConnectException,ConnectionSetupException );  
 
           raises( NoConnectException,ConnectionSetupException );  
 
   };  
 
   };  
 
+
  </source>
 
The acceptor service is used in the listening process while the connector service is used in the actively connecting service. The methods <code>accept()</code> and <code>connect()</code> get the connection string as a parameter. This is the connection part of the UNO URL (between ''uno:'' and '';urp'').  
 
The acceptor service is used in the listening process while the connector service is used in the actively connecting service. The methods <code>accept()</code> and <code>connect()</code> get the connection string as a parameter. This is the connection part of the UNO URL (between ''uno:'' and '';urp'').  
  
Line 76: Line 77:
  
  
{{Documentation/Tip|You can add more kinds of interprocess connections by implementing connector and acceptor services, and choosing the service name by the scheme com.sun.star.connection.Connector.<connection-type>, where <connection-type> is the name of the new connection type.
+
{{Tip|You can add more kinds of interprocess connections by implementing connector and acceptor services, and choosing the service name by the scheme com.sun.star.connection.Connector.<connection-type>, where <connection-type> is the name of the new connection type.
  
 
If you implemented the service com.sun.star.connection.Connector.mytype, use the UnoUrlResolver with the URL <tt>uno:mytype,param1<nowiki>=</nowiki>foo;urp;StarOffice.ServiceManager</tt> to establish the interprocess connection to the office.}}
 
If you implemented the service com.sun.star.connection.Connector.mytype, use the UnoUrlResolver with the URL <tt>uno:mytype,param1<nowiki>=</nowiki>foo;urp;StarOffice.ServiceManager</tt> to establish the interprocess connection to the office.}}
  
 
{{PDL1}}
 
{{PDL1}}
[[Category: Professional UNO]]
+
 
 +
[[Category:Documentation/Developer's Guide/Professional UNO]]

Latest revision as of 20:19, 14 July 2018



The method to import a UNO object using the UnoUrlResolver has drawbacks as described in the previous chapter. The layer below the UnoUrlResolver offers full flexibility in interprocess connection handling.

UNO interprocess bridges are established on the com.sun.star.connection.XConnection interface, which encapsulates a reliable bidirectional byte stream connection (such as a TCP/IP connection).

  interface XConnection: com::sun::star::uno::XInterface
  { 
      long read( [out] sequence < byte > aReadBytes , [in] long nBytesToRead ) 
           raises( com::sun::star::io::IOException ); 
      void write( [in] sequence < byte > aData ) 
           raises( com::sun::star::io::IOException ); 
      void flush( ) raises( com::sun::star::io::IOException ); 
      void close( ) raises( com::sun::star::io::IOException ); 
      string getDescription(); 
  };

There are different mechanisms to establish an interprocess connection. Most of these mechanisms follow a similar pattern. One process listens on a resource and waits for one or more processes to connect to this resource.

This pattern has been abstracted by the services com.sun.star.connection.Acceptor that exports the com.sun.star.connection.XAcceptor interface and com.sun.star.connection.Connector that exports the com.sun.star.connection.XConnector interface.

  interface XAcceptor: com::sun::star::uno::XInterface
  { 
      XConnection accept( [in] string sConnectionDescription ) 
           raises( AlreadyAcceptingException, 
                   ConnectionSetupException, 
                   com::sun::star::lang::IllegalArgumentException); 
 
      void stopAccepting(); 
  };
 
  interface XConnector: com::sun::star::uno::XInterface
  { 
      XConnection connect( [in] string sConnectionDescription ) 
           raises( NoConnectException,ConnectionSetupException ); 
  };

The acceptor service is used in the listening process while the connector service is used in the actively connecting service. The methods accept() and connect() get the connection string as a parameter. This is the connection part of the UNO URL (between uno: and ;urp).

The connection string consists of a connection type followed by a comma separated list of name-value pairs. The following table shows the connection types that are supported by default.

Connection type
socket Reliable TCP/IP socket connection
Parameter Description
host Hostname or IP number of the resource to listen on/connect. May be localhost. In an acceptor string, this may be 0 ('host=0'), which means, that it accepts on all available network interfaces.
port TCP/IP port number to listen on/connect to.
tcpNoDelay Corresponds to the socket option tcpNoDelay. For a UNO connection, this parameter should be set to 1 (this is NOT the default - it must be added explicitly). If the default is used (0), it may come to 200 ms delays at certain call combinations.
pipe A named pipe (uses shared memory). This type of interprocess connection is marginally faster than socket connections and works only if both processes are located on the same machine. It does not work on Java by default, because Java does not support named pipes directly
Parameter Description
name Name of the named pipe. Can only accept one process on name on one machine at a time.


Tip.png You can add more kinds of interprocess connections by implementing connector and acceptor services, and choosing the service name by the scheme com.sun.star.connection.Connector.<connection-type>, where <connection-type> is the name of the new connection type.

If you implemented the service com.sun.star.connection.Connector.mytype, use the UnoUrlResolver with the URL uno:mytype,param1=foo;urp;StarOffice.ServiceManager to establish the interprocess connection to the office.


Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages