unit fd_utils;\r
 interface\r
 \r
+const\r
+    FDwordshift=5;\r
+    FDwordmaxbit=(1 shl FDwordshift)-1;\r
+\r
 type\r
-    FDSet= Array [0..255] of longint; {31}\r
+    FDword=longint;\r
+    FDSet= Array [0..255] of fdword; {31}\r
     PFDSet= ^FDSet;\r
 \r
 Procedure FD_Clr(fd:longint;var fds:fdSet);\r
 { Remove fd from the set of filedescriptors}\r
 begin\r
   if (fd < 0) then raise exception.create('FD_Clr fd out of range: '+inttostr(fd));\r
-  fds[fd shr 5]:=fds[fd shr 5] and (not (1 shl (fd and 31)));\r
+  fds[fd shr fdwordshift]:=fds[fd shr fdwordshift] and (not (1 shl (fd and fdwordmaxbit)));\r
 end;\r
 \r
 Procedure FD_Zero(var fds:fdSet);\r
 { Add fd to the set of filedescriptors }\r
 begin\r
   if (fd < 0) then raise exception.create('FD_set fd out of range: '+inttostr(fd));\r
-  fds[fd shr 5]:=fds[fd shr 5] or (1 shl (fd and 31));\r
+  fds[fd shr fdwordshift]:=fds[fd shr fdwordshift] or (1 shl (fd and fdwordmaxbit));\r
 end;\r
 \r
 Function FD_IsSet(fd:longint;var fds:fdSet):boolean;{$ifdef useinline}inline;{$endif}\r
     result := false;\r
     exit;\r
   end;\r
-  FD_IsSet:=((fds[fd shr 5] and (1 shl (fd and 31)))<>0);\r
+  FD_IsSet:=((fds[fd shr fdwordshift] and (1 shl (fd and fdwordmaxbit)))<>0);\r
 end;\r
 end.\r
 
   tempsocket    : tlasio  ;\r
   socketcount   : integer ; // for debugging perposes :)\r
   dw,bt:integer;\r
+  currentfdword:fdword;\r
   fd : integer;\r
 begin\r
   //writeln('entering processasios');\r
 \r
   {------- test optimised loop}\r
   socketcount := 0;\r
-  for dw := (maxs shr 5) downto 0 do if (fdsr[dw] or fdsw[dw]) <> 0 then begin\r
-    for bt := 0 to 31 do if (fdsr[dw] or fdsw[dw]) and (1 shl bt) <> 0 then begin\r
+  for dw := (maxs shr fdwordshift) downto 0 do if (fdsr[dw] or fdsw[dw]) <> 0 then begin\r
+    currentfdword := (fdsr[dw] or fdsw[dw]);\r
+    for bt := fdwordmaxbit downto 0 do if currentfdword and (1 shl bt) <> 0 then begin\r
       inc(socketcount);\r
-      fd := dw shl 5 or bt;\r
+      fd := dw shl fdwordshift or bt;\r
       //writeln('reversing fd ',fd);\r
       currentsocket := fdreverse[fd];\r
       {if not assigned(currentsocket) then raise exception.create('currentsocket not assigned');\r