     public func close() throws {
         let res = sysClose(self.descriptor)
         guard res >= 0 else {
-            throw IOError(errno: errno, reason: "close(...) failed")
+            throw IOError(errno: errno, reason: reasonForError(function: "close"))
         }
         self.open = false
     }
+
+    private func reasonForError(function: String) -> String {
+        if let strError = String(utf8String: strerror(errno)) {
+            return "\(function) failed: \(strError)"
+        } else {
+            return "\(function) failed"
+        }
+    }
 }

        }
        
        guard getsockopt(self.descriptor, level, name, val, &length) != -1 else {
            throw IOError(errno: errno, reason: "getsockopt failed")
        }
        return val.pointee
    }

            &val,
            socklen_t(MemoryLayout.size(ofValue: val))
            ) != -1 else {
                throw IOError(errno: errno, reason: reasonForError(function: "setsockopt"))
        }
    }
    
