| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,7 +51,6 @@ public class Client implements Runnable { | |||
| 51 | 51 | ||
| 52 | 52 | Thread thread; | |
| 53 | 53 | Socket socket; | |
| 54 | - String ip; | ||
| 55 | 54 | int port; | |
| 56 | 55 | String host; | |
| 57 | 56 | ||
@@ -77,7 +76,6 @@ public Client(PApplet parent, String host, int port) { | |||
| 77 | 76 | socket = new Socket(this.host, this.port); | |
| 78 | 77 | input = socket.getInputStream(); | |
| 79 | 78 | output = socket.getOutputStream(); | |
| 80 | - ip = socket.getInetAddress().getHostAddress(); | ||
| 81 | 79 | ||
| 82 | 80 | thread = new Thread(this); | |
| 83 | 81 | thread.start(); | |
@@ -124,7 +122,6 @@ public Client(PApplet parent, Socket socket) throws IOException { | |||
| 124 | 122 | ||
| 125 | 123 | input = socket.getInputStream(); | |
| 126 | 124 | output = socket.getOutputStream(); | |
| 127 | - ip = socket.getInetAddress().getHostAddress(); | ||
| 128 | 125 | ||
| 129 | 126 | thread = new Thread(this); | |
| 130 | 127 | thread.start(); | |
@@ -276,7 +273,10 @@ public boolean active() { | |||
| 276 | 273 | * @brief Returns the IP address of the machine as a String | |
| 277 | 274 | */ | |
| 278 | 275 | public String ip() { | |
| 279 | - return ip; | ||
| 276 | + if (socket != null){ | ||
| 277 | + return socket.getInetAddress().getHostAddress(); | ||
| 278 | + } | ||
| 279 | + return null; | ||
| 280 | 280 | } | |
| 281 | 281 | ||
| 282 | 282 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments