gpt4 book ai didi

ios - 通过 NMSSH 的数据流

转载 作者:行者123 更新时间:2023-11-28 22:31:25 24 4
gpt4 key购买 nike

您好,我想为 OSX 开发一个 SSH 应用程序,我一直在研究 NMSSH ,它建立在 libssh2 之上。我该如何处理以下用例:

The application user sends a ping command to the server. => the result is continious responses

NMSSH 的方法是发送命令获取响应并将其放入 NSString 中,请参见下文。但是我如何处理一个案例,例如 ping 响应不断的地方。我是否需要使用另一个 SSH 包来实现此功能?

NMSSHSession *session = [NMSSHSession connectToHost:@"127.0.0.1:22"
withUsername:@"user"];

if (session.isConnected) {
[session authenticateByPassword:@"pass"];

if (session.isAuthorized) {
NSLog(@"Authentication succeeded");
}
}

NSError *error = nil;
NSString *response = [session.channel execute:@"ls -l /var/www/" error:&error];
NSLog(@"List of my sites: %@", response);

BOOL success = [session.channel uploadFile:@"~/index.html" to:@"/var/www/9muses.se/"];

[session disconnect];

最佳答案

正确的答案是结合使用库的 shell 功能和 channel 委托(delegate)的回调方法。在库中发现了一些问题,但自 issue #20 起已修复

关于ios - 通过 NMSSH 的数据流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17327991/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com