com.ericsson.otp.erlang
Class OtpSelf
java.lang.Object
|
+--com.ericsson.otp.erlang.OtpNode
|
+--com.ericsson.otp.erlang.OtpSelf
- Direct Known Subclasses:
- OtpServer
- public class OtpSelf
- extends OtpNode
Represents a local OTP client-only node. It is used when it will be
neccessary for this node to connect to remote nodes, but when it is
not necessary for other nodes to be able to connect to this one.
When the Java node will be connecting to a remote Erlang, Java
or C node, it must first identify itself as a node by creating an
instance of this class, after which it may connect to the remote
node.
This class does not bind a socket to a listen port as OtpServer
does, so it cannot be used when you want other nodes to
be able to establish connections to this one. However it can make
outgoing connections to other nodes as follows:
OtpSelf self = new OtpSelf("client","authcookie"); // identify self
OtpPeer other = new OtpPeer("server"); // identify peer
OtpConnection conn = self.connect(other); // connect to peer
- See Also:
OtpServer
Constructor Summary |
OtpSelf(java.lang.String node,
java.lang.String cookie)
Create a self node. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
OtpSelf
public OtpSelf(java.lang.String node,
java.lang.String cookie)
- Create a self node.
- Parameters:
node
- the name of this node.cookie
- the authorization cookie that will be used by this
node when it communicates with other nodes.
pid
public OtpErlangPid pid()
- Get the Erlang PID that will be used as the sender id in all
messages sent by this node.
- Returns:
- the Erlang PID that will be used as the sender id in
all messages sent by this node.
connect
public OtpConnection connect(OtpPeer other)
throws java.io.IOException,
java.net.UnknownHostException,
OtpAuthException
- Open a connection to a remote node.
- Parameters:
other
- the remote node to which you wish to connect.- Returns:
- a connection to the remote node.
- Throws:
- java.net.UnknownHostException - if the remote host could
not be found.
- java.io.IOException - if it was not possible to connect
to the remote node.
- OtpAuthException - if the connection was refused by the
remote node.