private Socket initBytestreamSocket(final String sessionID,
String initiator, String target) throws Exception {
ProxyProcess process;
try {
process = establishListeningSocket();
}
catch (IOException io) {
process = null;
}
String localIP;
try {
localIP = discoverLocalIP();
}
catch (UnknownHostException e1) {
localIP = null;
}
Bytestream query = createByteStreamInit(initiator, target, sessionID,
localIP, (process != null ? process.getPort() : 0));
Socket conn = waitForUsedHostResponse(sessionID, process, createDigest(
sessionID, initiator, target), query).establishedSocket;
cleanupListeningSocket();
return conn;
}