785 |
785 |
786 stats = function( ) |
786 stats = function( ) |
787 return _readtraffic, _sendtraffic, _readlistlen, _sendlistlen, _timerlistlen |
787 return _readtraffic, _sendtraffic, _readlistlen, _sendlistlen, _timerlistlen |
788 end |
788 end |
789 |
789 |
790 local dontstop = true; -- thinking about tomorrow, ... |
790 local quitting; |
791 |
791 |
792 setquitting = function (quit) |
792 setquitting = function (quit) |
793 dontstop = not quit; |
793 quitting = not not quit; |
794 return; |
794 end |
795 end |
795 |
796 |
796 loop = function(once) -- this is the main loop of the program |
797 loop = function( ) -- this is the main loop of the program |
797 if quitting then return "quitting"; end |
798 while dontstop do |
798 if once then quitting = "once"; end |
|
799 repeat |
799 local read, write, err = socket_select( _readlist, _sendlist, _selecttimeout ) |
800 local read, write, err = socket_select( _readlist, _sendlist, _selecttimeout ) |
800 for i, socket in ipairs( write ) do -- send data waiting in writequeues |
801 for i, socket in ipairs( write ) do -- send data waiting in writequeues |
801 local handler = _socketlist[ socket ] |
802 local handler = _socketlist[ socket ] |
802 if handler then |
803 if handler then |
803 handler.sendbuffer( ) |
804 handler.sendbuffer( ) |