Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
D.  Frequently Asked Questions Questions If another session is attached, does the first session get killed?  Previous   Contents   Next 
   
 

How can processes on different machines communicate using the ToolTalk service?

There are two ways in which processes on different machines can communicate using the ToolTalk service.

  1. They can connect to the same session.

  2. They can scope to a file that is NFS mounted on the machines involved.

Connecting to the Same Session

To connect the processes to the same session, you first need to determine a common interest for the processes (for example, a scheme that associates a session name with the common interest of the processes) and then you need to determine how to propagate the session name to all of the processes. The ToolTalk service does not provide a mechanism to distribute the session address (other than the possible advertisement of a session id on the TT_SESSION property of the root windows of X servers).

To get a session name, you can use the command

ttsession -p

which forks off a new session and prints its name to stdout; or you can the command:

ttsession -c

which sets the environment variable $TT_SESSION to the session id.

You then need to use some mechanism to put that session name in a place where the other processes can find it. Some examples of where you can place the session name are:

  • a shared file

  • a .plan file

  • a mail message

  • a separate RPC call of your own design

  • NIS

    For example, one approach using a well-known file in a NFS-exported file system can be done as follows:

    1. Start ttsession with the following command:

      ttsession -p >/home/foo/sessionaddress
    2. Ensure that the clients use the session address from the file; for example, wrap the clients in a shell script which reads the session address and sets SUN_TT_SESSION as follows:

        #!/bin/csh
        setenv TT_SESSION `cat /home/foo/sessionaddress`
        exec client-program

Alternately, the processes can use the session name in the tt_default_session_set call to connect to that session.

You could also send messages in the ttsession associated with a particular X server to advertise the newly-created ttsessions.

Scoping to a NFS-mounted File

File scoping is when a process registers a file scope pattern. The name of that session is placed on a list in rpc.ttdbserverd that is associated with the registered file. When a file-scoped message is sent, the ToolTalk service retrieves the list of sessions for the file and forwards the message to each of the sessions on the rpc.ttdbserverd list for that file.


Note - To scope to a file that is NFS-mounted on the machines involved requires a file system to be NFS mounted on all the systems and rpc.ttdbserverd to be run on the NFS server.


What is the purpose of tt_default_session_set?

tt_default_session_set determines the ttsession to which a call to tt_open will connect.

How can a process connect to more than one session?

Table D-3 describes several default variables that are used when communicating with the ToolTalk service.

Table D-3 Some Default Variables

Variable

Description

procid

Set by tt_open. This variable identifies the client to ttsession.

ptype

Set by tt_ptype_declare.

file

Set when you join a file. If no file is set in the message, the file attribute is set to the default file.

If you use the API functions for getting and setting the procid, your application can switch between multiple sessions. For example,

connect to session 1
store the default procid in filename
connect to session 2,
store the default procid filename
restore associated default procid
interact with particular_session

Note - The default file and ptype are part of the current default procid. Changing the default procid also changes the default file and ptype to the default file and ptype associated with that procid.


Can you start a ttsession with a known session id?

No. You have to get the session id from the ToolTalk service.

What information does a session id contain?

The session id consists of a number of fields, including:

  • Version of address format

  • Unix pid of process

  • RPC Transient Program Number

  • Unused version (compatibility holdover)

  • Authorization level

  • User id

  • Host IP address

  • RPC version


Caution - The format of a session id is a private interface. Do not write ToolTalk clients that depend on the format of a session id.


 
 
 
  Previous   Contents   Next