Attempt to send args via socket connection.
Socket sck = null;
PrintWriter pw = null;
try {
String msg = "StartSocket: passing startup args to already-running Azureus java process listening on [127.0.0.1: 6880]";
// DON'T USE LOGGER here as we DON't want to initialise all the logger stuff
// and in particular AEDiagnostics config dirty stuff!!!!
System.out.println( msg );
sck = new Socket("127.0.0.1", 6880);
// NOTE - this formatting is also used by AzureusCoreSingleInstanceClient and other org.gudy.azureus2.ui.common.Main.StartSocket
pw = new PrintWriter(new OutputStreamWriter(sck.getOutputStream(),Constants.DEFAULT_ENCODING));
StringBuffer buffer = new StringBuffer(AzureusCoreSingleInstanceClient.ACCESS_STRING + ";args;");
for(int i = 0 ; i < args.length ; i++) {
String arg = args[i].replaceAll("&","&&").replaceAll(";","&;");
buffer.append(arg);
buffer.append(';");
}
pw.println(buffer.toString());
pw.flush();
return true;
}
catch(Exception e) {
e.printStackTrace();
Debug.printStackTrace( e );
return false; //there was a problem connecting to the socket
}
finally {
try {
if (pw != null) pw.close();
}
catch (Exception e) {}
try {
if (sck != null) sck.close();
}
catch (Exception e) {}
}