Giter Site home page Giter Site logo

hgncxzy / androidhttpclient Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 140 KB

Android 设备间通过 TCP 进行局域网通信,该项目作为客户端使用。请配合 AndroidHttpServer(https://github.com/hgncxzy/AndroidHttpServer) 项目作为服务器使用。

Kotlin 100.00%

androidhttpclient's Introduction

AndroidHttpClient

Android 设备间通过 TCP 进行局域网通信,该项目作为客户端使用。请配合 AndroidHttpServer 项目作为服务器使用。

说明

  1. PC 分配给所有的模拟器 IP 地址均为 10.0.2.2
  2. 模拟器之间是无法直接进行通讯的,必须通过端口映射,比如将模拟器 M1 6302 的端口映射到模拟器 M2 的 7302 端口,映射成功后,就可以通过模拟器 M1 的 10.0.2.2:6302 地址访问到模拟器 M2 的 10.0.2.2:7302 地址。

模拟器调试步骤

  1. 同时打开服务端模拟器、客户端模拟器
  2. 执行如下命令,关联端口映射 adb -s emulator-5554 forward tcp:6302 tcp:7302

ps:将 emulator-5554 替换为你本地的服务器端模拟器名称,另外客户端端口 6302 和服务端端口 7302 均为自定义端口,可更改。

真机调试步骤

  1. 设定服务端固定 IP,并修改客户端请求 URL 为该 IP 地址
  2. 客户端连接服务端 WIFI,保证在同一局域网
  3. 客户端发起网络请求,即可收到服务端数据回调

参考

  1. 多个Android模拟器之间如何进行通信

androidhttpclient's People

Contributors

hgncxzy avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.