Today I will show you:
Client / server socket programming example in Android and simple java program
The Android Client application will send message to java server program running on local host
Java server program
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
public class MyServer {
public static void main(String[] args) throws IOException {
Socket clientSocket = null;
ServerSocket serverSocket = null;
try{
serverSocket = new ServerSocket(4444);
System.out.println("server started....");
clientSocket = serverSocket.accept();
}catch(Exception e){}
//read & display the message
//BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
Scanner in1 = new Scanner(clientSocket.getInputStream());
String mes;
while(true){
if (in1.hasNext())
{
mes=in1.nextLine();
System.out.println("Client message :"+mes);
}
}
}
}
How to get the Android Emulator's ip address at : • How to get the Android Emulator's ip address
In questa pagina del sito puoi guardare il video online android socket programming example della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Akash Rajguru 04 giugno 2014, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 50,211 volte e gli è piaciuto 150 spettatori. Buona visione!