Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void getNewServer(String modi) {
- Socket client = null;
- OutputStream out = null;
- PrintWriter writer = null;
- InputStream in = null;
- BufferedReader reader = null;
- String ip = "";
- String port = "";
- String nummer = "";
- try {
- client = new Socket("localhost", 5555);
- out = client.getOutputStream();
- writer = new PrintWriter(out);
- in = client.getInputStream();
- reader = new BufferedReader(new InputStreamReader(in));
- writer.write("new Server " + modi);
- writer.flush();
- String s = null;
- while((s = reader.readLine()) != null) {
- if(s.startsWith("ip")) {
- ip = s.substring(3);
- }
- if(s.startsWith("port")) {
- port = s.substring(5);
- }
- if(s.startsWith("nummer")) {
- nummer = s.substring(7);
- }
- }
- } catch(Exception e) {
- getNewServer(modi);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement