org.jgroups.blocks
Class Link
public
class
Link
extends Object
implements Runnable
Implements a physical link between 2 parties (point-to-point connection). For incoming traffic,
a server socket is created (bound to a given local address and port). The receiver thread does the
following: it accepts a new connection from the server socket and (on the same thread) reads messages
until the connection breaks. Then it goes back to accept(). This is done in 2 nested while-loops.
The outgoing connection is established when started. If this fails, the link is marked as not established.
This means that there is not outgoing socket.
A heartbeat will be exchanged between the 2 peers periodically as long as the connection is established
(outgoing socket is okay). When the connection breaks, the heartbeat will stop and a connection establisher
thread will be started. It periodically tries to re-establish connection to the peer. When this happens
it will stop and the heartbeat thread will resume.
For details see Link.txt
Author: Bela Ban, June 2000
Constructor Summary |
| Link(String local_addr, int local_port, String remote_addr, int remote_port) |
| Link(String local_addr, int local_port, String remote_addr, int remote_port, Link.Receiver r) |
| Link(String local_addr, int local_port, String remote_addr, int remote_port, long timeout, long hb_interval, Link.Receiver r) |
public Link(String local_addr, int local_port, String remote_addr, int remote_port)
public Link(String local_addr, int local_port, String remote_addr, int remote_port,
Link.
Receiver r)
public Link(String local_addr, int local_port, String remote_addr, int remote_port, long timeout, long hb_interval,
Link.
Receiver r)
public boolean equals(Object other)
public boolean established()
public InetAddress getLocalAddress()
public int getLocalPort()
public InetAddress getRemoteAddress()
public int getRemotePort()
public int hashCode()
public static void main(String[] args)
public void run()
Receiver thread main loop. Accept a connection and then read on it until the connection
breaks. Only then is the next connection handled. The reason is that there is only supposed
to be 1 connection to this server socket at the same time.
public boolean send(byte[] buf)
Tries to send buffer across out socket. Tries to establish connection if not yet connected.
public void setTrace(boolean t)
public void start()
public void stop()
public String toString()
This piece of code would only accept connections from the peer address defined above.
Copyright ? 1998-2005 Bela Ban. All Rights Reserved.