}
AddRef(File reference){
Socket fcpSocket = null;
FCPMessage fcpm;
SimpleFieldSet sfs = new SimpleFieldSet(true);
try{
fcpSocket = new Socket("127.0.0.1", FCPServer.DEFAULT_FCP_PORT);
fcpSocket.setSoTimeout(2000);
InputStream is = fcpSocket.getInputStream();
LineReadingInputStream lis = new LineReadingInputStream(is);
OutputStream os = fcpSocket.getOutputStream();
try{
sfs.putSingle("Name", "AddRef");
sfs.putSingle("ExpectedVersion", "2.0");
fcpm = FCPMessage.create("ClientHello", sfs);
fcpm.send(os);
os.flush();
String messageName = lis.readLine(128, 128, true);
sfs = getMessage(lis);
fcpm = FCPMessage.create(messageName, sfs);
if((fcpm == null) || !(fcpm instanceof NodeHelloMessage)){
System.err.println("Not a valid FRED node!");
System.exit(1);
}
} catch(MessageInvalidException me){
me.printStackTrace();
}
try{
sfs = SimpleFieldSet.readFrom(reference, false, true);
fcpm = FCPMessage.create(AddPeer.NAME, sfs);
fcpm.send(os);
os.flush();
// TODO: We ought to do stricter checking!
// FIXME: some checks even
} catch(MessageInvalidException me){