问题描述
我已经设置了VPN服务,然后配置了VPN接口。
private void setupVPN() {
try {
if (vpnInterface == null) {
Builder builder = new Builder();
builder.addAddress(VPN_ADDRESS,32);
builder.addRoute(VPN_ROUTE,0);
builder.setMtu(1499);
vpnInterface = builder.setSession(getString(R.string.app_name)).setConfigureIntent(pendingIntent).establish();
}
} catch (Exception e) {
Log.e(TAG,"error",e);
System.exit(0);
}
}
我可以从文件描述符中读取字节,但如何将其写回。
FileChannel vpnInput = new FileInputStream(vpnFileDescriptor).getChannel();
FileChannel vpnOutput = new FileOutputStream(vpnFileDescriptor).getChannel();
Thread t = new Thread(new WriteVpnThread(vpnOutput,networkToDeviceQueue));
t.start();
try {
ByteBuffer bufferToNetwork = null;
while (!Thread.interrupted()) {
bufferToNetwork = ByteBufferPool.acquire();
int readBytes = vpnInput.read(bufferToNetwork);
if (readBytes > 0) {
bufferToNetwork.flip();
}
}
}
我必须先解析它们,然后再写回去吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)