diff --git a/Sources/BaseSocket.swift b/Sources/BaseSocket.swift index 54dde73f4..6cfab40bb 100644 --- a/Sources/BaseSocket.swift +++ b/Sources/BaseSocket.swift @@ -102,7 +102,7 @@ public class BaseSocket : Selectable { let res = Darwin.close(self.descriptor) #endif guard res >= 0 else { - throw IOError(errno: errno, reason: "shutdown(...) failed") + throw IOError(errno: errno, reason: "close(...) failed") } self.open = false } diff --git a/Sources/main.swift b/Sources/main.swift index 953af89bb..64c7b12ed 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -103,6 +103,8 @@ do { // Accept new connections until there are no more in the backlog while let accepted = try socket.accept() { try accepted.setNonBlocking() + try accepted.setOption(level: SOL_SOCKET, name: SO_REUSEADDR, value: 1) + // Allocate an 8kb buffer for reading and writing and register the socket with the selector let buffer = Buffer(capacity: 8 * 1024)