|
|
Workaround Solution for the 10 User Windows XP Pro Maximum Connections Limit
Posted by: David on Jan 14, 2006 - 04:30 PM
windows-php
|
|
If you're using Windows XP Pro as a file server and often run into problems where users can't connect to because the 10 maximum simulaneous connections have been reached (or 5 maximum connections for XP Home) - here's a quick and simple solution via PHP. The script basically uses "net session", parses the output and looks for idle connections and disconnects them- in this case if they've been idle for a second or don't have any open files. Combine this with some sort of cron app for Windows (I recommend PyCron), and it works terrifically:
<?php
//disconnects windows share sessions with any sort of idle time and doesn't //have any open files; combine with cron for windows:
//from David @ PHP4IT.com 2006-01-14
$cmd = "net session";
exec($cmd, $out);
$disconnect_these = array();
foreach ($out as $line){
$line = trim($line);
if (substr($line, 0, 2) != "\\\\"){ continue; }
$t = explode(':', $line);
$idle_time = substr($t[0], -1);
$open_files = explode(' ', $t[0]);
$open_files = $open_files[sizeof($open_files)-2];
if ($idle_time > 0 || !$open_files){
$computer_name = trim(substr($line, 0, 17));
$disconnect_these[] = $computer_name;
#print "$computer_name\t$idle_time\t$open_files\n";
}
}
if (sizeof($disconnect_these)){
foreach ($disconnect_these as $disconnect){
passthru("net session $disconnect /delete /Y");
}
}
#print_r($disconnect_these);
?>
Here's the sample crontab entry to run the script, which we're calling disconnect_idle_sessions.php, to run every minute:
* * * * * c:\php\php c:\php\disconnect_idle_sessions.php
|
|
| Workaround Solution for the 10 User Windows XP Pro Maximum Connections Limit | Log-in or register a new user account | 0 Reviews/Comments |
|
| Reviews and Comments are opinion statements made by the author. They do not necessarily represent the opinions of the site editor. |
|