android socket programming example

Publicado el: 04 junio 2014
en el canal de: Akash Rajguru
50,211
150

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  


En esta página del sitio puede ver el video en línea android socket programming example de Duración hora minuto segunda en buena calidad , que subió el usuario Akash Rajguru 04 junio 2014, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 50,211 veces y le gustó 150 a los espectadores. Disfruta viendo!