android - updpacket.send throws exception -


here code dont know why udp_packet.send(outgoing); throws exception

               int serverport = 9876;                inetaddress server_ip = inetaddress.getbyname("127.0.0.1");                     // send udp packet                 datagramsocket udp_packet = new datagramsocket(serverport);                 udp_packet.setbroadcast(true);                  string fxx = latcrd.gettext().tostring();                 string fyy = longcrd.gettext().tostring();                  string str = fxx + "," + fyy;                 byte[] b = str.getbytes();                 datagrampacket outgoing = new datagrampacket(b, b.length,                         server_ip, serverport);                 try{                 udp_packet.send(outgoing);                  }                 catch(exception e)                 {                     e.printstacktrace();                 } 

prevoiusly ok stop working , dont knw whats problem

okay got answer of own question. sending udp packet on network in main thread , not allow send packet on network in main thread. thanks


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -