From ffb10a59cfe09c679f9dd1cbfe11eb795b2d7674 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 28 Apr 2017 14:57:57 +0200 Subject: [PATCH] Cleanup --- Sources/BaseSocket.swift | 2 +- Sources/main.swift | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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)