[jcifs] Infinite loop in server enumeration
Eric Glass
eric.glass at gmail.com
Thu Jul 1 11:11:23 GMT 2004
Mike,
The NetServerEnum stuff appears to be getting caught in an infinite
loop (for me anyways); it enumerates over the same list of servers and
eventually gets an out of memory error. I'm sending you a separate
message with an example output (sorry about the size; I'm hoping you
have mailbox quota for it). The ServerManagement class from my RAP
package gets through the list okay, so it's probably just a loop
termination condition issue. Here's what I'm using to list the
servers:
import jcifs.smb.SmbFile;
public class Enumerate {
public static void main(String[] args) throws Exception {
System.setProperty("jcifs.properties", "jcifs.properties");
SmbFile file = new SmbFile(args[0]);
SmbFile[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
System.out.println(files[i]);
}
}
}
The analogous listing using ServerManagement is:
import jcifs.rap.server.ServerConstants;
import jcifs.rap.server.ServerInfo;
import jcifs.rap.server.ServerManagement;
public class EnumerateRap {
public static void main(String[] args) throws Exception {
System.setProperty("jcifs.properties", "jcifs.properties");
ServerManagement servers = new ServerManagement(args[0]);
ServerInfo[] info = servers.netServerEnum(1,
ServerConstants.SV_TYPE_ALL, args[0]);
int length = info.length;
for (int i = 0; i < length; i++) {
System.out.println(info[i].name);
}
}
}
Eric
More information about the jcifs
mailing list