简体   繁体   中英

Client to Client communication over PHP server for Android App

What is the best way to connect an android application and a php server?

  1. Using sockets (TCP request)
  2. HTTP request

I am trying to implement a chat system between multiple clients, but I know that PHP does not allow multithreads for sockets.

I basically want to create an app simmilar to google latitude, and I also want to implement a chat system between the users. I have aldready decided that I am going to use a MySQl DB and therefore a PHP server so the client communicates with the DB (using JSON for data exchange). I found out that the easiest way to do this is using HTTP requests, but I don't know exactly how I should implement this.

I am quite new to this and I don't know how the architecture Client-Server-Client communication should look like. Could you give me some guidelines about how to do this? Or if there is any other easier way?

What is the best way to connect an android application and a php server?

1.Using sockets (TCP request)

2.HTTP request

it depends , if you use sokects (TCP request) it will be more secure and you will transfer a small amount of data to the server for each request so there is a small traffic , but it is harder to implement over http request , http request is not secure and will carry alot of data for each request ie(Http headers) so there is more traffic.

read about (push technologies) http://en.wikipedia.org/wiki/Push_technology

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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