Thanks for your project. When I want to start ServerSocket locally in this app to receive requests, I can never receive the client connection. Below is the code I added based on this project:
// step1 :start a local serverSocket for accpect tun2socks connection in this app
localSocksServer = new ServerSocket(port);
Log.e("LocalSocks Server", "Start run on port: " + port);
while (TProxyService.shouldRunLocalSocksServer) {
Socket client = localSocksServer.accept();
// here can not accept a connection? why ?
Log.e("LocalSocks Server", "Accept client connection");
vpnService.protect(client);
new Thread(new Runnable() {
@Override
public void run() {
try {
OutputStream clientOuts = client.getOutputStream();
int readN = 0;
byte[] bytes = new byte[65535];
while ((readN = ins.read(bytes)) != -1) {
Log.e("Socks Server", "Received Data=" + new String(bytes, 0, readN));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
// step2: begin tun2socks on this app
builder.setSession(session);
tunFd = builder.establish();
if (tunFd == null) {
stopSelf();
return;
}
Thanks for your project. When I want to start ServerSocket locally in this app to receive requests, I can never receive the client connection. Below is the code I added based on this project:
// step1 :start a local serverSocket for accpect tun2socks connection in this app localSocksServer = new ServerSocket(port); Log.e("LocalSocks Server", "Start run on port: " + port); while (TProxyService.shouldRunLocalSocksServer) { Socket client = localSocksServer.accept(); // here can not accept a connection? why ? Log.e("LocalSocks Server", "Accept client connection"); vpnService.protect(client); new Thread(new Runnable() { @Override public void run() { try { OutputStream clientOuts = client.getOutputStream(); int readN = 0; byte[] bytes = new byte[65535]; while ((readN = ins.read(bytes)) != -1) { Log.e("Socks Server", "Received Data=" + new String(bytes, 0, readN)); } } catch (Exception e) { e.printStackTrace(); } } }).start(); }
// step2: begin tun2socks on this app builder.setSession(session); tunFd = builder.establish(); if (tunFd == null) { stopSelf(); return; }