}
public int connect(Address masterAddress, Address localAddress,
AgentXSession session) throws IOException {
AgentXPeer peer = (AgentXPeer) peers.get(masterAddress);
TransportMapping transport;
if (peer == null) {
transport = addMaster(localAddress);
peer = new AgentXPeer(transport, masterAddress);
}
else {
transport = peer.getTransport();
agentX.removeTransportMapping(transport);
agentX.addTransportMapping(transport);
if (!transport.isListening()) {
transport.listen();
}
}
peer.setTimeout(session.getTimeout());
session.setPeer(peer);
int status = AgentXProtocol.AGENTX_TIMEOUT;