use of net.i2p.util.I2PThread in project i2p.i2p by i2p.
the class TestSwarm method connectWithPeers.
private void connectWithPeers() {
if (_peerDestFiles != null) {
for (int i = 0; i < _peerDestFiles.length; i++) {
try {
FileInputStream fin = new FileInputStream(_peerDestFiles[i]);
byte[] dest = new byte[1024];
int read = DataHelper.read(fin, dest);
String remDest = new String(dest, 0, read);
int con = 0;
Flooder flooder = null;
synchronized (_remotePeers) {
con = _remotePeers.size() + 1;
flooder = new Flooder(con, remDest);
_remotePeers.put(new Integer(con), flooder);
}
byte[] msg = (DataHelper.getUTF8("STREAM CONNECT ID=" + con + " DESTINATION=" + remDest + "\n"));
synchronized (_samOut) {
_samOut.write(msg);
_samOut.flush();
}
I2PThread flood = new I2PThread(flooder, "Flood " + con);
flood.start();
_log.debug("Starting flooder with peer from " + _peerDestFiles[i] + ": " + con);
} catch (IOException ioe) {
_log.error("Unable to read the peer from " + _peerDestFiles[i]);
}
}
}
}
use of net.i2p.util.I2PThread in project i2p.i2p by i2p.
the class TestStreamTransfer method startAlice.
private static void startAlice(String host, int port, String conOptions) {
_log.info("\n\nStarting up Alice");
try {
Socket s = new Socket(host, port);
OutputStream out = s.getOutputStream();
out.write(DataHelper.getASCII("HELLO VERSION MIN=1.0 MAX=1.0\n"));
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
String line = reader.readLine();
_log.debug("line read for valid version: " + line);
String req = "SESSION CREATE STYLE=STREAM DESTINATION=Alice " + conOptions + "\n";
out.write(DataHelper.getASCII(req));
line = reader.readLine();
_log.info("Response to creating the session with destination Alice: " + line);
req = "NAMING LOOKUP NAME=ME\n";
out.write(DataHelper.getASCII(req));
line = reader.readLine();
Properties props = SAMUtils.parseParams(line);
String value = props.getProperty("VALUE");
if (value == null) {
_log.error("No value for ME found! [" + line + "]");
return;
} else {
_log.info("Alice is located at " + value);
}
_alice = value;
I2PThread aliceThread = new I2PThread(new AliceRunner(reader, out, s));
aliceThread.setName("Alice");
aliceThread.start();
} catch (Exception e) {
_log.error("Error testing for valid version", e);
}
}
use of net.i2p.util.I2PThread in project i2p.i2p by i2p.
the class TestStreamTransfer method testBob.
private static void testBob(String sessionName, String host, int port, String conOptions) {
I2PThread t = new I2PThread(new TestBob(sessionName, host, port, conOptions), sessionName);
t.start();
}
use of net.i2p.util.I2PThread in project i2p.i2p by i2p.
the class StreamSinkServer method startup.
public void startup(I2PServerSocket sock) {
for (int i = 0; i < _handlers; i++) {
I2PThread t = new I2PThread(new ClientRunner(sock));
t.setName("Handler " + i);
t.setDaemon(false);
t.start();
}
}
use of net.i2p.util.I2PThread in project i2p.i2p by i2p.
the class TestSwarm method startup.
public void startup() {
_log.debug("Starting up");
File keys = new File(_destFile);
if (!keys.exists()) {
try {
I2PClientFactory.createClient().createDestination(new FileOutputStream(keys));
} catch (Exception e) {
_log.error("Error creating a new destination on " + keys, e);
return;
}
}
try {
_manager = I2PSocketManagerFactory.createManager(new FileInputStream(_destFile), null, -1, null);
} catch (Exception e) {
_log.error("Error creatign the manager", e);
return;
}
I2PThread listener = new I2PThread(new Listener(), "Listener");
listener.start();
connectWithPeers();
}
Aggregations