Posted to tcl by colin at Sat Nov 17 10:04:40 GMT 2018view raw

  1. lassign $argv overhead
  2.  
  3. if {$overhead eq ""} {
  4. set overhead 3
  5. }
  6.  
  7. try {
  8. # calculate o/s max fd limit for Linux
  9. lindex [split [exec -- prlimit --output SOFT --nofile] \n] end
  10. } on ok {maxfiles} {
  11. # works for Linux
  12. } on error {e eo} {
  13. set maxfiles 1024 ;# I have no idea what value this is for your system
  14. }
  15. puts stderr maxfiles:$maxfiles
  16.  
  17. set count [llength [chan names]]
  18. while {$count < $maxfiles-$overhead} {
  19. open [info script]
  20. incr count
  21. }
  22. puts Opened:[llength [chan names]]
  23.  
  24. proc Connected {args} {
  25. puts stderr Connected:$args
  26. }
  27.  
  28. ::socket -server ::Connected 8091
  29.  
  30. vwait forever