changed samv3 because of reverted streaming and mstreaming libs

This commit is contained in:
mkvore-commit
2009-05-05 12:39:14 +00:00
parent fceec5c129
commit 30b73ffe6d

View File

@ -266,20 +266,17 @@ public class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handle
{ {
while (session.socketServer!=null) { while (session.socketServer!=null) {
// wait and accept a connection from I2P side
I2PSocket i2ps = null ; I2PSocket i2ps = null ;
try { try {
session.socketServer.waitIncoming(0); i2ps = session.socketServer.accept();
} catch (ConnectException e) { } catch (Exception e) {}
_log.debug("ConnectException");
break ; if (i2ps==null) {
} catch (I2PException e) { continue ;
_log.debug("I2PServerSocket has been closed");
break ;
} catch (InterruptedException e) {
_log.debug("InterruptedException");
break ;
} }
// open a socket towards client
java.net.InetSocketAddress addr = new java.net.InetSocketAddress(host,port); java.net.InetSocketAddress addr = new java.net.InetSocketAddress(host,port);
SocketChannel clientServerSock = null ; SocketChannel clientServerSock = null ;
@ -289,17 +286,14 @@ public class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handle
catch ( IOException e ) { catch ( IOException e ) {
continue ; continue ;
} }
if (clientServerSock==null) {
try { try {
i2ps = session.socketServer.accept(1); i2ps.close();
} catch (Exception e) {}
if (i2ps==null) {
try {
clientServerSock.close();
} catch (IOException ee) {} } catch (IOException ee) {}
continue ; continue ;
} }
// build pipes between both sockets
try { try {
if (this.verbose) if (this.verbose)
SAMv3Handler.notifyStreamIncomingConnection( SAMv3Handler.notifyStreamIncomingConnection(
@ -308,10 +302,8 @@ public class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handle
ReadableByteChannel fromI2P = Channels.newChannel(i2ps.getInputStream()); ReadableByteChannel fromI2P = Channels.newChannel(i2ps.getInputStream());
WritableByteChannel toClient = clientServerSock ; WritableByteChannel toClient = clientServerSock ;
WritableByteChannel toI2P = Channels.newChannel(i2ps.getOutputStream()); WritableByteChannel toI2P = Channels.newChannel(i2ps.getOutputStream());
I2PAppThread send = new I2PAppThread(new Pipe(fromClient,toI2P, "SAMPipeClientToI2P"), "SAMPipeClientToI2P"); (new I2PAppThread(new Pipe(fromClient,toI2P, "SAMPipeClientToI2P"), "SAMPipeClientToI2P")).start();
I2PAppThread recv = new I2PAppThread(new Pipe(fromI2P,toClient, "SAMPipeI2PToClient"), "SAMPipeI2PToClient"); (new I2PAppThread(new Pipe(fromI2P,toClient, "SAMPipeI2PToClient"), "SAMPipeI2PToClient")).start();
send.start();
recv.start();
} catch (IOException e) { } catch (IOException e) {
try { try {