FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Changed ip() to return null when client has disconnected · pkdevbox/processing@4c15dc3 · GitHub

Repository navigation

Commit 4c15dc3

Browse files
committed
Changed ip() to return null when client has disconnected
1 parent c348334 commit 4c15dc3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎java/libraries/net/src/processing/net/Client.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public class Client implements Runnable {
5151

5252
Thread thread;
5353
Socket socket;
54-
String ip;
5554
int port;
5655
String host;
5756

@@ -77,7 +76,6 @@ public Client(PApplet parent, String host, int port) {
7776
socket = new Socket(this.host, this.port);
7877
input = socket.getInputStream();
7978
output = socket.getOutputStream();
80-
ip = socket.getInetAddress().getHostAddress();
8179

8280
thread = new Thread(this);
8381
thread.start();
@@ -124,7 +122,6 @@ public Client(PApplet parent, Socket socket) throws IOException {
124122

125123
input = socket.getInputStream();
126124
output = socket.getOutputStream();
127-
ip = socket.getInetAddress().getHostAddress();
128125

129126
thread = new Thread(this);
130127
thread.start();
@@ -276,7 +273,10 @@ public boolean active() {
276273
* @brief Returns the IP address of the machine as a String
277274
*/
278275
public String ip() {
279-
return ip;
276+
if (socket != null){
277+
return socket.getInetAddress().getHostAddress();
278+
}
279+
return null;
280280
}
281281

282282

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL