[libsmbclient] Windows XP 10 connection limit

Derrell Lipman derrell.lipman at unwireduniverse.com
Tue Oct 7 02:41:58 GMT 2008

On Mon, Oct 6, 2008 at 4:45 PM, ZeWaren / Erwan Martin <main at zewaren.net>wrote:

> Hi,
> I'm building a small script that scans my local network and lists the files
> located on it.
> I'm using libsmbclient to get the list of shares on each computer.
> However, when I scan windows XP computers, I can only open 10 shares on
> them, then I get some 'access denied' errors. I google that problem and
> found out that this limit is normal, ie you can only open 10 connections to
> a windows xp computer.
> Since I only open one share at a time, why am I facing that limit?
> I'm using these three functions:
> smbc_init
> smbc_opendir
> smbc_readdir
> smbc_closedir
> Is there a way for samba not to open a new connection for each share?
> Or is there a way to close a connection manually?

Hi Erwan,

If you look in libsmbclient.h, you'll find this:

 * Set whether to use the same connection for all shares on a server.
 * Some Windows versions appear to have a limit to the number
 * of concurrent SESSIONs and/or TREE CONNECTions.  In
 * one-shot programs (i.e. the program runs and then quickly
 * ends, thereby shutting down all connections), it is
 * probably reasonable to establish a new connection for each
 * share.  In long-running applications, the limitation can be
 * avoided by using only a single connection to each server,
 * and issuing a new TREE CONNECT when the share is accessed.
smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b);

If you set this option to true, your problem should go away.



More information about the samba-technical mailing list