libsmbclient: Connection reset by peer when reconnecting to a host.

Tim Hutt tdh29 at
Thu Nov 17 15:19:15 GMT 2005

On Wednesday 16 November 2005 22:34, derrell at wrote:
> > The thing you suggested didn't help though... Any other suggestions?
> Not off hand.  Do you get the same problem if you connect repeatedly to a
> smaller number of servers?  If so, does the problem happen after the same
> (approximate) number of connections as in your original test?

No, it doesn't seem to matter how many connections - I tried connecting to 10 
in a loop and that segfaulted too (even though it didn't actually manage to 
connect to any of them). I will try to investigate more and let you know.

> > Also, I have some more general questions about libsmbclient:
> >
> > a) Is it at all thread safe? What if I use more than one context?
> The internals of Samba, as used by the client library, are not thread safe.
> I'd stick with separate processes rather than threads if you need multiple
> concurrent access.
> Although using multiple contexts makes the top layer of the client library
> somewhat thread safe, it's calling lots of deeper code which was never
> built to be thread safe.


> > b) What is a context?
> It's initialization state and cached connection state.  There are default
> callback functions and default values for context variables.  You can
> change some of those, as your application requires.  See libsmbclient.h for
> an explanation of the context structure (struct _SMBCCTX).
> > c) Do you have to actually fill in all the callbacks in the context thing
> > or can you leave them as NULL so that it uses some default
> > implementation?
> The callbacks need to be set, but they are initialized to defaults for you
> by smbc_new_context() which is called by smbc_init().

Ahh ok.

> > d) Is there a way to get the NetBIOS name from an IP using libsmbclient?
> Probably, but that one I'd have to research.  I don't recall ever trying to
> do that.  You can get the NetBIOS name using "nmblookup -S" so if you look
> at the source code to nmblookup, you may be able to figure out what
> libsmbclient functions you'd have to call to do something similar.

Ok, I'll try that.

> ps. Please continue to cc: samba-technical on further
> questsions/discussion, so it's all saved in the archive.


More information about the samba-technical mailing list