android socket programming example

Published: 04 June 2014
on channel: 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  


On this page of the site you can watch the video online android socket programming example with a duration of hours minute second in good quality, which was uploaded by the user Akash Rajguru 04 June 2014, share the link with friends and acquaintances, this video has already been watched 50,211 times on youtube and it was liked by 150 viewers. Enjoy your viewing!