     }
 }
 
-public enum HttpServerIOState: Int{
+public enum HttpServerIOState: Int32 {
     case Starting
     case Running
     case Stopping

    
    private var socket = Socket(socketFileDescriptor: -1)
    private var sockets = Set<Socket>()
    public private(set) var state = HttpServerIOState.Stopped
    public var operating: Bool { get { return self.state == .Running } }
    
    public func port() throws -> Int {
        return Int(try socket.port())

        self.state = .Starting
        self.socket = try Socket.tcpSocketForListen(port, forceIPv4: forceIPv4)
        dispatch_async(dispatch_get_global_queue(priority, 0)) { [weak self] in
            guard let `self` = self else { return }
            guard self.operating else { return }
            while let socket = try? self.socket.acceptClientSocket() {
                dispatch_async(dispatch_get_global_queue(priority, 0), { [weak self] in
                    guard let `self` = self else { return }
                    guard self.operating else { return }
                    dispatch_async(self.queue) {
                        self.sockets.insert(socket)
                    }
                    self.handleConnection(socket)
                    dispatch_async(self.queue) {
                        self.sockets.remove(socket)
                    }
                })
            }
            self.stop()
        }
        self.state = .Running
    }
