1

libssh2 を使用してリモート コンピューターにログインし、次に libssh2_channel_exec を呼び出してデーモン プログラムを実行します。デーモン プログラムは利用可能な tcpip ポートを選択し、選択した prot をコンソール (stdio) に出力します。次に、デーモンは着信接続のポートをリッスンします。これらのステップの後、クライアントは「libssh2_channel_read」によって stdio から選択された tcp ポートを読み取ります。正しい値を取得できます。しかし、問題は次のとおりです。libssh2 チャネル (libssh2_channel_close()) を閉じると、リモート プログラムが終了するまでプログラムがブロックされます。リモート プログラムを閉じずにチャネルを閉じる方法はありますか? ログインと使用可能な prot 番号にのみ ssh を使用するため、これで十分です。

また、リモートプログラムは Qt の QCoreApplication を使用するため、利用可能な prot を出力した後、クライアントに応答するために app.exec() のイベントループに入りますので、ポート番号を出力した直後に終了してはいけません。

4

1 に答える 1

0

There a function in libssh2 can solve my problem..:) "libssh2_session_set_blocking" libssh_session_set_blocking(mysession,0);//this will set the libssh2 working whith non-blocking mode.

The left work to do is ensure the client read all the output of the server, without blocking ,I must control the EOF myself. :) Thanks Stackoverflow, thanks google!

于 2010-06-21T14:53:22.720 に答える