Advertisement
Guest User

Untitled

a guest
Aug 30th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. public static void getNewServer(String modi) {
  2.  
  3. Socket client = null;
  4. OutputStream out = null;
  5. PrintWriter writer = null;
  6. InputStream in = null;
  7. BufferedReader reader = null;
  8.  
  9. String ip = "";
  10. String port = "";
  11. String nummer = "";
  12.  
  13. try {
  14. client = new Socket("localhost", 5555);
  15. out = client.getOutputStream();
  16. writer = new PrintWriter(out);
  17.  
  18. in = client.getInputStream();
  19. reader = new BufferedReader(new InputStreamReader(in));
  20.  
  21. writer.write("new Server " + modi);
  22. writer.flush();
  23.  
  24. String s = null;
  25.  
  26. while((s = reader.readLine()) != null) {
  27. if(s.startsWith("ip")) {
  28. ip = s.substring(3);
  29. }
  30. if(s.startsWith("port")) {
  31. port = s.substring(5);
  32. }
  33.  
  34. if(s.startsWith("nummer")) {
  35. nummer = s.substring(7);
  36. }
  37.  
  38. }
  39.  
  40.  
  41.  
  42. } catch(Exception e) {
  43. getNewServer(modi);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement