1
votes

I have PHP server that opens a socket connection and start listening on specific port. I have to write an android client that sends data to the server. Then server reads a socket for incoming data and writes its response to the socket. Data exchanged are the series of strings. How would I get this communication possible? What kind of protocol is used?

Kindly give me the direction.

Thanks.

Iyra

1

1 Answers

-1
votes

Use the URLConnection class. Here's a sample code to read data from a uri. To write data, use getOutputStream()

URL url = new URL("ftp://example.com/example.html");
URLConnection urlConnection = url.openConnection();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
try {
  readStream(in);
} finally {
  in.close();
}