안드로이드로 소켓 통신을 하는데 처음 접속후 입력했을땐 잘 동작하다가 입력없이 일정 시간이 지난뒤 다시 입력을 하면 전혀 동작이 되지 않습니다. 이건 어떤 현상때문에 발생 되는 건가요??
class ConnectThread extends Thread{ //통신 시작
String hostname;
int portname;
public ConnectThread(String IP, String PORT){
hostname=IP;
portname=Integer.parseInt(PORT);
}
public void run() {
try{
socket = new Socket(hostname, portname);
bufferoutstream = new BufferedOutputStream(socket.getOutputStream());
readBuffer = new byte[1024];
readBuffer = data.getBytes();
bufferoutstream.write(readBuffer);
bufferoutstream.flush();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
}
public class ConnectThread2 extends Thread { //ON-OFF
public void run() {
try {
if(socket!=null) {
readBuffer = new byte[1024];
readBuffer = data.getBytes();
bufferoutstream.write(readBuffer);
bufferoutstream.flush();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}