java - Android Socket - second attempt fails with ETIMEDOUT -


the following code called once second. appears work first time fails on subsequent calls java.netconnectexception etimedout. receiving device microchip wifi module 1 port.

private void senddata() {     new thread() {         @override         public void run() {             try {                 socket socket = null;                 dataoutputstream dataout = null;                 try {                     if (socket == null) {                         socket = new socket("1.2.3.4", 2000);                     }                     dataout = new dataoutputstream(socket.getoutputstream());                     dataout.writeutf(datastring());                     l.d("send");                 } catch (unknownhostexception e) {                     e.printstacktrace();                  } catch (ioexception e) {                     e.printstacktrace();                 } {                     if (socket != null) {                         try {                             socket.close();                             l.d("skt close");                         } catch (ioexception e) {                             e.printstacktrace();                         }                     }                 }                  if (dataout != null) {                     try {                         dataout.close();                     } catch (ioexception e) {                         // todo auto-generated catch block                         e.printstacktrace();                     }                 }             } catch (exception e) {                 log.d("exception in thread", e.getstacktrace() + "");             }         }     }.start(); } 


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -