Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void run() {
- try{
- ServerSocket ss=new ServerSocket(puerto);
- int contador=0;
- while(!end){
- try{
- ss.setSoTimeout(6000);
- Socket s=ss.accept();
- BufferedReader input=new BufferedReader(new InputStreamReader(s.getInputStream()));
- PrintWriter output=new PrintWriter(s.getOutputStream());
- stringData=input.readLine();
- output.flush();
- contador++;
- try{
- Thread.sleep(1000);
- }catch (InterruptedException e){
- e.printStackTrace();
- }
- output.close();
- s.close();
- }catch (SocketTimeoutException e){
- e.printStackTrace();
- }finally {
- end=true;
- }
- }
- ss.close();
- }catch (IOException e){
- e.printStackTrace();
- }
- }
- public void onClick(View view) {
- dirIP=editTextDirIP.getText().toString();
- hebraRecibir.start();
- hebraEnviar.start();
- while(comprobacion){
- if(ThreadRecibir.isEnd()){
- Toast.makeText(getApplicationContext(),"la hebra se ha parado",Toast.LENGTH_LONG).show();
- comprobacion=false;
- hebraRecibir.interrupt();
- hebraEnviar.interrupt();
- }
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement