java - TCP sender android -


please tell me simple example of sending message protocol tcp android. how implement method of sand (ipserver,port);

string host = ...; // host name can either machine name, such "java.sun.com", or textual representation of ip address int port = ...; socket socket = new socket(inetaddress.getbyname(host), port); bufferedreader reader = new bufferedreader(new inputstreamreader(socket.getinputstream())); printwriter writer = new printwriter(socket.getoutputstream(), true); // true auto flush 

now, can send message through writer, like:

writer.println("hello world"); 

and can read incoming data through reader, like:

string incoming = reader.readline(); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -