Https服务器在macOS上工作但在iOS上不起作用

时间:2017-08-07 09:31:34

标签: ios swift https server cocoaasyncsocket

我写了一个简单的https服务器,只响应" Hello world"。 该项目使用lib CocoaAsyncSocket进行通信。

func socket(_ sock: GCDAsyncSocket, didAcceptNewSocket newSocket: GCDAsyncSocket) {
    let session = Session(socket: newSocket)
    session.delegate = self
    sessions.append(session)

    slog("https server receive new socket")
    newSocket.enableBackgroundingOnSocket()
    if let items = self.sslItems { // Enable https
        newSocket.startTLS([kCFStreamSSLIsServer as String: kCFBooleanTrue, kCFStreamSSLCertificates as String: items, kCFStreamSSLValidatesCertificateChain as String : kCFBooleanFalse])
    }
    session.begin()
}

public func begin() {
    socket.delegate = self
    socket.readData(to: termData, withTimeout: -1, tag: SocketReadTag.readRequestHeader.rawValue)
    slog("read request header")
}

我无法读取任何数据。为什么呢?

0 个答案:

没有答案