Home > Software engineering >  Libssh2 library implementation of SSH client program how to obtain connection signal by the server
Libssh2 library implementation of SSH client program how to obtain connection signal by the server

Time:09-16

Using libssh2 SSH client library development, through the session - & gt; Openchannel channel_read/channel the write way with centos server SSHD communications, such as

Now if the exit system according to the exit after I login system, but the client don't know how to respond to the connection disconnect message,

Tried to register libssh2_session_callback_set LIBSSH2_CALLBACK_DISCONNECT callback function, and also couldn't get to the callback,
After the server disconnected, channel write or perform (oddly) success, also unable to determine connection broken by the way,

Consult everybody who is there any way to determine active server disconnected

CodePudding user response:

Personal guess ha, get a thread libssh2_channel_wait_closed?
Not to use the underlying WSAEventSelect recognised & amp; Monitor FD_CLOSE events

CodePudding user response:

Try:
LIBSSH2_POLLFD_SESSION_CLOSED
LIBSSH2_POLLFD_CHANNEL_CLOSED

CodePudding user response:

The server disconnected need disconnect? If an exception is disconnected, there is no news??

CodePudding user response:

https://stackoverflow.com/questions/12981125/libssh2-session-cleanup-without-blocking

The second answer is likely to be useful, he seems to trigger recv, but reading byte 0, through the remote disconnect, network part seems similar to ordinary socket, it's just a deal,

CodePudding user response:

reference 1st floor zgl7903 response:
personal guess ha, get a thread libssh2_channel_wait_closed?
Not to use the underlying WSAEventSelect recognised & amp; Monitor FD_CLOSE events


My socket is to use asynchronous, fd close message didn't response, regarding channel_wait_closed, I see that, seems to be in the call waiting after the close shut a success,

CodePudding user response:

refer to tiger, 4/f, bobo response:

https://stackoverflow.com/questions/12981125/libssh2-session-cleanup-without-blocking
The second answer is likely to be useful, he seems to trigger recv, but reading byte 0, through the remote disconnect, network part, and the ordinary socket seems almost just is a protocol,

Thank you, I should see the two functions with links!

CodePudding user response:

Disconnect should have a message, I'm not abnormal disconnect test now, it is normal to exit,
  • Related