0

I want to create a pair of Android app (Server - Client) using Socket to communicate with each other in real time. I found the sample here http://androidsrc.net/android-client-server-using-sockets-server-implementation/ which works. The client can connect to the server. Now I think about making the server a... "web server" (I don't know if I'm calling it the right way) that can display what they (server and client) are communicating (maybe showing their chat or calculation...).

But when I type in the address and port (eg: http://172.16.1.21:8080/) into the browser (Chrome), the result is

172.16.1.21 sent an invalid response. ERR_INVALID_HTTP_RESPONSE

I guess it was responding but with some other kind of format that the browser doesn't understand. I tried calling with postman and got the error:

Could not get any response There was an error connecting to 172.16.1.21:8080.

I tried putting an index.html to the root of the storage (/storage/emulated/0/) but no luck

The idea would be the same as the app "Websharing" on store. All you need is that the phone and the Computer is on the same network. When access the app, the browser will show the content of the phone.

My idea is to show other information. I though about creating another "display-app" to show the result, but then what if I wan't to send some custom message to all client, then I will need an another phone, which is so difficult to have. Opening another tab is much easier. I don't want to risk using online service like Firebase because the internet connection may not be stable. Just local connection is fine for me.

I don't know that is it called, a keyword would be appreciated. I tried googling and found some suggestion that to run an app called "Tiny web server", I haven't tried it but I don't wan't to use a third-party app because the installation will be complicated and not support full customization.

Thank you for your time.

Tran Hoai Nam
  • 1,273
  • 2
  • 18
  • 35
  • The browser and webserver communicate using a higher-level protocol called HTTP From the client side, you might find [this question](https://stackoverflow.com/questions/9233316/what-is-the-smallest-possible-http-and-https-data-request) interesting. For the server side, you might have a look at [this question](https://stackoverflow.com/questions/6329468/how-to-create-a-http-server-in-android). They can at least get you started. – President James K. Polk Jul 01 '19 at 13:44
  • Thank you, I'll have a look – Tran Hoai Nam Jul 01 '19 at 14:36

0 Answers0