Getting notification upon loss of connection (libsmbclient)

Michael B. Allen miallen at eskimo.com
Thu Mar 13 08:01:26 GMT 2003


On Wed, 12 Mar 2003 16:07:43 -0500
Derrell.Lipman at UnwiredUniverse.com wrote:

> I have not been able to find the block of code that will be called if an open
> connection receives an indication that the peer has "gone away"
> (i.e. shutdown, crashed, cable cut, etc.).
> 
> More specifically, if I have an open, established connection by having
> previously done:
> 
>   cli_connect()
>   cli_session_request()
>   cli_session_setup()
>   cli_send_tconX()
> 
> and now the remote server goes away (let's say it crashed suddenly), how can I
> find this out?

I'm not familiar with libsmbclient but I believe you will just have to
try to perform some operation and catch the error code. If the error
codes are consistent (e.g. EIO) you can trap and reinitialize the request
in a way that would be transparent to the user. Otherwise the library
would need to send NBT keepalives or use an out of band heartbeat
of some kind. Smbclient sort of does this by repeatedly sending an
SMB_COM_CHECK_DIRECTORY every 3 seconds. That probably serves a similar
purpose. But this is a TCP thing, not a libsmbclient thing.

Mike

-- 
A  program should be written to model the concepts of the task it
performs rather than the physical world or a process because this
maximizes  the  potential  for it to be applied to tasks that are
conceptually  similar and, more important, to tasks that have not
yet been conceived. 


More information about the samba-technical mailing list