Skip to content

Commit c348334

Browse files
committed
Fixes Issue processing#2576 NPE when calling ip() on disconnected clients.
1 parent 00c2eb7 commit c348334

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public Client(PApplet parent, String host, int port) {
7777
socket = new Socket(this.host, this.port);
7878
input = socket.getInputStream();
7979
output = socket.getOutputStream();
80+
ip = socket.getInetAddress().getHostAddress();
8081

8182
thread = new Thread(this);
8283
thread.start();
@@ -123,6 +124,7 @@ public Client(PApplet parent, Socket socket) throws IOException {
123124

124125
input = socket.getInputStream();
125126
output = socket.getOutputStream();
127+
ip = socket.getInetAddress().getHostAddress();
126128

127129
thread = new Thread(this);
128130
thread.start();
@@ -274,7 +276,7 @@ public boolean active() {
274276
* @brief Returns the IP address of the machine as a String
275277
*/
276278
public String ip() {
277-
return socket.getInetAddress().getHostAddress();
279+
return ip;
278280
}
279281

280282

0 commit comments

Comments
 (0)