         descriptor = -1
     }
 
+    public var type: SocketType {
+        get {
+            var socketType: Int32 = 0
+            var length = socklen_t(sizeof(Int32))
+            
+            getsockopt(descriptor, SOL_SOCKET, SO_TYPE, &socketType, &length)
+            
+            return socketType
+        }
+    }
 
     public var reuse: Bool {
         get {

    }

    func listen(backlog: Int = 1) throws {
        let status = Darwin.listen(descriptor, Int32(backlog))
        if status != 0 {
            throw Errno(rawValue: errno) ?? Error.Unknown

    }

    func accept() throws -> (Socket, Address, UInt16) {
        precondition(type == SOCK_STREAM, "\(__FUNCTION__) should only be used on `SOCK_STREAM` sockets")
        
        var incoming = sockaddr()
        var incomingSize = socklen_t(sizeof(sockaddr))
        let socket = Darwin.accept(descriptor, &incoming, &incomingSize)
        if socket < 0 {
            throw Errno(rawValue: errno) ?? Error.Unknown
        }
        
        let (address, port) = try Address.fromSockaddr(incoming)
        return (Socket(socket), address, port)
    }
