我怎么能启动通过USB一个Android到PC的HTTP请求?我怎么能、USB、Android、PC

2023-09-05 07:25:38 作者:犊子

这一直是asked 过,但没有得到一个满意的答复。的

This has been asked before, but did not receive a satisfactory answer.

这是我的Andr​​oid应用程序,我需要发送一个HTTP请求,通过USB连接电脑。通常情况下,利用亚洲开发银行的沟通是单向的,从PC到Android。

From my Android application, I need to send an HTTP request to a PC attached via USB. Typically, communication using ADB is one-way, from PC to Android.

正如答案与上述重复的,这已被做过Android的USB端口转发。如果我真的需要,我可以下载这个程序,并把事情弄糟了,但我宁愿在我自己的应用程序实现这一点。

As mentioned in the answers to the aforementioned duplicate, this has been done before: Android Usb Port Forwarding. If I really needed to, I could just download this app and botch it, but I'd much rather implement this within my own app.

任何想法?

推荐答案

这其实不是它是单向的沟通,但能力的发起连接的。

It is not actually the communication which is one way, but the ability initiate connections.

要做到这一点与标准的Andr​​oid功能,您将在概念上有隧道通过现有的PC发起的连接的设备发起连接。例如,使用现成的工具:

To do this with standard android functionality, you will conceptually have to tunnel the device-initiated connections through an existing PC-initiated connection. For example, using off the shelf tools:

设置了一个ADB端口转发从PC到设备 运行在Android设备上的SSH服务器上对应的亚行期待一个非特权端口号 通过亚洲开发银行连接到手机上的SSH客户端的PC上前进,并成立了一个SSH着手机上的一个端口返回到PC 在一个端口 运行在PC上的监听SSH的目的端口转发上的服务器。 让您的code上的电话联系,通过了SSH端口转发在PC上的服务器 Set up an ADB port forward from PC to device Run an SSH server on the android device on an unprivileged port number corresponding to your adb forward Connect to the phone from an SSH client on the PC through the ADB forward, and set up an SSH forward of a port on the phone back to a port on the PC Run a server on the PC listening at the destination port of the SSH forward. Have your code on the phone contact the server on the PC via that SSH port forward

您实际上并不需要使用SSH,它只是这包东西准备使用的作品。

You don't actually have to use SSH, it's just that this packages up the pieces ready to use.

作为替代方案的想法,支持USB网络共享一些Android设备提供移动网络服务,电脑含蓄最终建立一个双向IP网络通过USB连接线,它可以用于其他用途。但要非常小心,你的所有电脑的网络流量通过手机不小心的路线。

As an alternative idea, some Android devices which support USB tethering to provide mobile network service to a PC implicitly end up creating a bi-directional IP network over the usb cable, which you can use for other purposes. But be very careful that you don't accidentally route all the PC's network traffic through the phone.

 
精彩推荐
图片推荐