简体   繁体   English

什么样的Android框架可用于将PC连接到Android和Android到其他PC?

[英]What framework of Android can be used to connect PC to Android and Android to other PC?

I have this scenario. 我有这种情况。 Where i am writing one apps in Android usging bash/python. 我在Android中使用bash / python编写一个应用程序。 So that via PC i can connect to the Android and from Android using USB i can connect the destination PC/Server. 因此,通过PC我可以连接到Android和从Android使用USB我可以连接目标PC /服务器。

But what API is available to send all my Android requests to USB, so that i can remotely have assistance for the Server PC via Android? 但是有什么API可用于将我的所有Android请求发送到USB,以便我可以通过Android远程获得对服务器PC的帮助? Is there any other available open-source framework for doing such? 有没有其他可用的开源框架这样做?

在此输入图像描述

or 要么

在此输入图像描述

Follow up: 跟进:

There is already "Tethering and portable hotspot" option in my mobile. 我的手机中已经有“Tet​​hering and portable hotspot”选项。 Without installing any third party apps. 无需安装任何第三方应用程序。

在此输入图像描述

So once i enabled it, i have new interface called usb0 with ip address in the same subnet of Android + Laptop. 所以,一旦我启用它,我有一个名为usb0的新界面,其IP地址位于Android + Laptop的同一子网中。

Then i installed simply SSHDroid server in Android, now from 3G i can connect to the Android. 然后我在Android上安装简单的SSHDroid服务器,现在从3G我可以连接到Android。 Now PC and Android both has usb0 interface with same subnet for sharing data that solves all the remote access problem. 现在PC和Android都有usb0接口和相同的子网,用于共享解决所有远程访问问题的数据。

On my laptop: 在我的笔记本上:

$ ip addr

    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether d4:be:d9:55:91:4a brd ff:ff:ff:ff:ff:ff
        inet 192.168.0.219/24 brd 192.168.0.255 scope global eth0
        inet6 fe80::d6be:d9ff:fe55:914a/64 scope link 
           valid_lft forever preferred_lft forever

    7: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
        link/ether c6:8a:95:bf:fa:2b brd ff:ff:ff:ff:ff:ff
        inet 192.168.42.202/24 brd 192.168.42.255 scope global usb0
        inet6 fe80::c48a:95ff:febf:fa2b/64 scope link 
           valid_lft forever preferred_lft forever

On my Android mobile: 在我的Android手机上:

/data/data/berserker.android.apps.sshdroid/home # ip addr

11: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 6e:54:53:29:68:8c brd ff:ff:ff:ff:ff:ff
    inet 192.168.42.129/24 brd 192.168.42.255 scope global usb0
    inet6 fe80::6c54:53ff:fe29:688c/64 scope link 
       valid_lft forever preferred_lft forever

15: wlan0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 50:01:bb:e3:fb:d7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.163/24 brd 192.168.0.255 scope global wlan0
    inet6 fe80::5201:bbff:fee3:fbd7/64 scope link 
       valid_lft forever preferred_lft forever

what you want to do should be possible but will require effort. 你想做什么应该是可能的,但需要付出努力。 There are apps to enable USB tethering but I don't think they work universally for all devices. 有些应用程序可以启用USB网络共享,但我认为它们并不适用于所有设备。 That can create a network you can use to communicate with the connected server. 这可以创建一个可用于与连接的服务器通信的网络。 If you install ssh server on the android, that can be used to tunnel your connection to the internal servers. 如果你在android上安装ssh服务器,那可以用来隧道连接到内部服务器。 Port forwarding is another option . 端口转发是另一种选择 I think you would most probably need a rooted phone. 我想你很可能需要一部扎根手机。 That if inbound connections to your phone are possible with your 3g carrier. 如果您的3g运营商可以与您的手机进行入站连接。

If inbound connections are not possible, then you can setup a script on your phone or one of the servers to try ssh a particular machine (your PC or home router) every 5 minutes creating a tunnel to internal network. 如果无法进行入站连接,则可以在手机或其中一台服务器上设置脚本,每隔5分钟尝试ssh一台特定的计算机(您的PC或家用路由器),从而创建到内部网络的隧道。

To have stable hostnames you can use some dynamic dns service like dnsdynamic.org because your public IP addresses would most probably change at least on the 3G end. 要拥有稳定的主机名,您可以使用dnsdynamic.org之类的动态DNS服务,因为您的公共IP地址很可能至少在3G端发生变化。

I think though that it would be far easier to just buy a cheap router box with USB for a 3G dongle. 我认为虽然购买带有USB的廉价路由器盒用于3G加密狗会容易得多。 Or you can put a 3G dongle into one of your servers and use it as a router. 或者您可以将3G加密狗放入其中一台服务器并将其用作路由器。 Actually you can try using your android phone as a USB modem dongle, I'm finding this guide . 实际上你可以尝试使用你的Android手机作为USB调制解调器加密狗,我找到了这个指南

It all depends on particular device capabilities and luck but in conclusion, if it was me, I would first try using the android phone as a usb modem dongle and use a dynamic dns service so I always know the current IP of the 3G connection. 这一切都取决于特定的设备功能和运气,但最后,如果是我,我会首先尝试使用Android手机作为USB调制解调器加密狗并使用动态DNS服务,所以我总是知道3G连接的当前IP。 Then use ssh to connect to the server running the 3G connection. 然后使用ssh连接到运行3G连接的服务器。 From that server one can ssh to any other server. 从该服务器可以ssh到任何其他服务器。 Then I would try using a dedicated router with some usb 3G dongle. 然后我会尝试使用带有一些usb 3G加密狗的专用路由器。 I would never go for the hassle configuring an android phone working as a router, sounds too time consuming. 我永远不会为配置作为路由器的Android手机而烦恼,听起来太费时间了。

Hope that helps. 希望有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM