我已经关注此链接并使用VpnService创建了Vpn接口.在将前向路由添加为"0.0.0.0"时,所有互联网流量都被转发到Vpn接口.我可以读取数据包,访问协议,目标IP和端口.
现在我试图通过tcp套接字将数据包转发到目的地.但是套接字连接失败并且连接超时.
exception: java.net.ConnectException: failed to connect to /74.125.227.114 (port 443): connect failed: ETIMEDOUT (Connection timed out)
Run Code Online (Sandbox Code Playgroud)
注意:当我尝试使用相同的ip和端口连接套接字但没有Vpn时,它会连接.无法弄清楚我哪里出错了?
粘贴下面的代码:
public class VpnServiceEx extends VpnService implements Handler.Callback, Runnable {
private static final String TAG = "VpnServiceEx";
private Handler mHandler;
private Thread mThread;
private ParcelFileDescriptor mInterface;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// The handler is only used to show messages.
if (mHandler == null) {
mHandler = new Handler(this);
}
// Stop the previous session …Run Code Online (Sandbox Code Playgroud)