|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ericsson.otp.erlang.OtpNode | +--com.ericsson.otp.erlang.OtpSelf | +--com.ericsson.otp.erlang.OtpServer
Represents a local OTP client or server node. It is used when you
want other nodes to be able to establish connections to this one.
When you create an instance of this class, it will bind a socket to
a port so that incoming connections can be accepted. However the
port number will not be made available to other nodes wishing to
connect until you explicitely register with the port mapper daemon
by calling publishPort()
.
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.
Setting up a connection may be done as follows:
OtpServer self = new OtpServer("server","cookie"); // identify self self.publishPort(); // make port information available OtpConnection conn = self.accept(); // get incoming connection
OtpSelf
Constructor Summary | |
OtpServer(OtpSelf self)
Create an OtpServer from an existing OtpSelf . |
|
OtpServer(java.lang.String node,
java.lang.String cookie)
Create an OtpServer, using a vacant port chosen by the operating system. |
|
OtpServer(java.lang.String node,
java.lang.String cookie,
int port)
Create an OtpServer, using the specified port number. |
Method Summary | |
OtpConnection |
accept()
Accept an incoming connection from a remote node. |
int |
port()
Get the port number used by this node. |
boolean |
publishPort()
Make public the information needed by remote nodes that may wish to connect to this one. |
void |
unPublishPort()
Unregister the server node's name and port number from the Erlang port mapper, thus preventing any new connections from remote nodes. |
Methods inherited from class com.ericsson.otp.erlang.OtpSelf |
connect,
pid |
Methods inherited from class com.ericsson.otp.erlang.OtpNode |
alive,
cookie,
host,
node,
setCookie,
toString |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public OtpServer(OtpSelf self) throws java.io.IOException
OtpServer
from an existing OtpSelf
.self
- an existing self node.public OtpServer(java.lang.String node, java.lang.String cookie) throws java.io.IOException
port()
method.node
- the name of the node.cookie
- the authorization cookie that will be used by this
node when accepts connections from remote nodes.public OtpServer(java.lang.String node, java.lang.String cookie, int port) throws java.io.IOException
node
- a name for this node, as above.cookie
- the authorization cookie that will be used by this
node when accepts connections from remote nodes.port
- the port number to bind the socket to.Method Detail |
public int port()
public boolean publishPort() throws java.io.IOException
This method will fail if an Epmd process is not running on the localhost. See the Erlang documentation for information about starting Epmd.
Note that once this method has been called, the node is
expected to be available to accept incoming connections. For that
reason you should make sure that you call accept()
shortly after calling publishPort()
. When you no longer
intend to accept connections you should call unPublishPort()
.
public void unPublishPort()
public OtpConnection accept() throws java.io.IOException, OtpAuthException
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |