How to implement an HTTP server on android

前端 未结 3 1962
时光说笑
时光说笑 2020-12-31 17:10

I\'ve two android applications on same LAN provided by WIFI :

  1. App (A) that open a listening socket on port 8033
  2. App (B) that use HttpClient to access
3条回答
  •  滥情空心
    2020-12-31 17:48

    Listening on a port and accepting socket connections isn't enough to serve data back to HttpClient. Sockets in effect provide a physical pipe but know nothing about the format of the data that's flowing along that pipe. If you are set on using HttpClient, then you'll need to have your server application understand HTTP protocol (or at least a very basic subset of it).

    If all you need is to have two processes communicate in some way, you may be better off having your server app be a service and then your client app interrogate this service for the required data.

提交回复
热议问题