Android program to read any data from the known ip address

BufferedReader br;
Socket requestorSocket;
try

{

requestorSocket=new  Socket(“192.168.2.254”,2222);
System.out.println(“connected”);
br= new BufferedReader(new InputStreamReader(requestorSocket.getInputStream()));
System.out.println(“receving data”);
while(true)
{
if((ss=br.readLine())!=null)
textView.setText(ss); // update the value in a textview

else

break; // break out of the loop if the reader returns a null value

}

}

catch(Exception e)
{
e.printStackTrace();
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s