Skip to content

Commit c0dc788

Browse files
Update ReadInputStream.java
1 parent 8af5c43 commit c0dc788

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/xdvrx1_serverProject/ReadInputStream.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ StringBuffer readUserRequest(BufferedInputStream bis,
2020
if (userRequest.length() > bufferSize-1) {
2121
//for performance, always shutdown
2222
//after breaking from this loop
23-
connection.shutdownInput();
23+
if (connection.isConnected()) {
24+
connection.shutdownInput();
25+
}
2426
break;
2527
}
2628

@@ -33,12 +35,12 @@ StringBuffer readUserRequest(BufferedInputStream bis,
3335
//ignore the line endings,
3436
//the Reader will interpret this as end of buffer
3537
//we need to read the entire content of the buffer
36-
if (c == '\n' || c == '\r' || c == 1) continue;
38+
if (c == '\n' || c == '\r' || c == -1) continue;
3739
}
3840
return userRequest;
3941
} catch (IOException ioe) {
4042
System.out.println(ioe.getMessage());
4143
return null;
4244
}
4345
}
44-
}
46+
}

0 commit comments

Comments
 (0)