diff --git a/README.md b/README.md
index 7ec37b1..cf6fe17 100644
--- a/README.md
+++ b/README.md
@@ -13,14 +13,14 @@ Maven:
com.arenareturns
SimpleNet
- 1.7.3
+ 1.7.4
```
Gradle:
```groovy
-implementation 'com.arenareturns:SimpleNet:1.7.3'
+implementation 'com.arenareturns:SimpleNet:1.7.4'
```
2. Because SimpleNet is compiled with Java 11, you must first require its module in your `module-info.java`:
diff --git a/pom.xml b/pom.xml
index cb380bb..de32a97 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.arenareturns
SimpleNet
- 1.7.3
+ 1.7.4
SimpleNet
ArenaReturns' fork of SimpleNet, an easy-to-use, event-driven, asynchronous network application framework compiled with Java 11.
diff --git a/src/main/java/com/arenareturns/simplenet/Server.java b/src/main/java/com/arenareturns/simplenet/Server.java
index 5605b72..2f19fca 100644
--- a/src/main/java/com/arenareturns/simplenet/Server.java
+++ b/src/main/java/com/arenareturns/simplenet/Server.java
@@ -46,6 +46,7 @@
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
+import jdk.net.ExtendedSocketOptions;
/**
* The entity that all {@link Client}s will connect to.
@@ -138,6 +139,16 @@ public void bind(String address, int port, int numThreads) {
channel.accept(null, new CompletionHandler() {
@Override
public void completed(AsynchronousSocketChannel channel, Void attachment) {
+ try {
+ // Configure TCP keepalive settings for the client connection
+ channel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
+ channel.setOption(ExtendedSocketOptions.TCP_KEEPCOUNT, 3);
+ channel.setOption(ExtendedSocketOptions.TCP_KEEPIDLE, 30);
+ channel.setOption(ExtendedSocketOptions.TCP_KEEPINTERVAL, 5);
+ } catch (IOException e) {
+ LOGGER.warn("Failed to set keepalive options on client socket", e);
+ }
+
Client client = new Client(channel);
connectedClients.add(client);
client.postDisconnect(() -> connectedClients.remove(client));