android socket programming example

Publicado em: 04 Junho 2014
no 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  


Nesta página do site você pode assistir ao vídeo on-line android socket programming example duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Akash Rajguru 04 Junho 2014, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 50,211 vezes e gostou 150 espectadores. Boa visualização!