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

From Apache OpenOffice Wiki
Jump to: navigation, search
m
m (FINAL VERSION FOR L10N)
Line 6: Line 6:
 
|NextPage=Documentation/DevGuide/ProUNO/Creating the Bridge
 
|NextPage=Documentation/DevGuide/ProUNO/Creating the Bridge
 
}}
 
}}
[[zh:Zh/Documentation/DevGuide/ProUNO/Opening a Connection]]
+
{{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.

Revision as of 07:59, 13 May 2009



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.


Template:Documentation/Tip

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