android - Send values to a dynamically genrated IP address -



android - Send values to a dynamically genrated IP address -

i developing app in mobile app acting server provides values dynamically generated ip. can help me acheving mechanism. have coded client in java as

package client; import java.io.ioexception; import java.net.datagrampacket; import java.net.datagramsocket; import java.net.inetaddress; public class simpleudpclient { public static void main(string[] args){ datagramsocket socket = null; datagrampacket inpacket = null; datagrampacket outpacket = null; byte[] inbuf, outbuf; final int port = 8888; string msg = null; seek { inetaddress address = inetaddress.getbyname("127.0.0.5"); socket = new datagramsocket(); //convert string byte , send server msg = "hello"; outbuf = msg.getbytes(); outpacket = new datagrampacket(outbuf, 0, outbuf.length, address, port); socket.send(outpacket); //receive reversed message server inbuf = new byte[256]; inpacket = new datagrampacket(inbuf, inbuf.length); socket.receive(inpacket); string info = new string(inpacket.getdata(), 0, inpacket.getlength()); system.out.println("server : " + data); } grab (ioexception ioe) { system.out.println(ioe); } } }

android

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -