Skip to content

Commit

Permalink
Stop the packet transfer if the socket is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
rtm516 committed Sep 6, 2024
1 parent 7df08f5 commit fdfad9a
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public int getSendLimit() {
public int receive(byte[] buf, int off, int len, int waitMillis) throws IOException {
if (socket.isClosed()) {
this.close();
return -1;
}
DatagramPacket packet = new DatagramPacket(buf, off, len);
socket.receive(packet);
Expand All @@ -41,6 +42,7 @@ public int receive(byte[] buf, int off, int len, int waitMillis) throws IOExcept
public void send(byte[] buf, int off, int len) throws IOException {
if (socket.isClosed()) {
this.close();
return;
}
socket.send(new DatagramPacket(buf, off, len));
}
Expand Down

0 comments on commit fdfad9a

Please sign in to comment.