Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1.  
  2. private String ipAddres = "192.168." + ad_ip.getText().toString();
  3.  
  4. //Jeżeli chcesz wywołać to połączenie na innym adresie IP to zmieniasz sobie w taki sposób:
  5. private void funkcjaGdzieWywolujeInnyIp{
  6. ipAddres = "192.168.0.1"; //to jest twoj nowy adres ip z którym chcesz sie połączyć
  7. new Thread1.start();
  8. }
  9.  
  10. class Thread1 extends Thread implements Runnable {
  11. Thread threadTest;
  12. public void run() {
  13. Socket socket = null;
  14. try {
  15. InetAddress serverAddr = InetAddress.getByName(ipAddres);
  16. socket = new Socket(serverAddr, SERVERPORT);
  17. Thread2 commThread = new Thread2(socket);
  18. threadTest = new Thread(commThread);
  19. threadTest.start();
  20. return;
  21. } catch (IOException e) {
  22. e.printStackTrace();
  23. }
  24. }
  25. public void stopThread(){
  26.  
  27. // this.stopThread();
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement