[MUD-Dev] Re: TECH: Distributed Muds

Derek Snider derek at idirect.com
Sun Apr 29 13:47:06 CEST 2001


>From Jon Lambert, April 27, 2001 3:39 PM
> Caliban Tiresias Darklock wrote:
>> On Thu, 26 Apr 2001 22:52:03 -0400, "Derek Snider"
>> <derek at idirect.com> wrote:
  
>>> Why not use select() to delay?  
  
>> Because select() is not a delay function. It's a network I/O
>> function.  If you are not doing network I/O, use a different
>> function -- sleep() comes to mind.  It's a religious issue, though.
 
> This from the Winsock Lame List 
> (90% of the list applies to Unices as well)
> -------cut------

First of all, I find it difficult to put too much faith in the
opinions of Windows programmers of how to do socket programming
under UNIX.
 
> 1) Calling select() with three empty fd_sets and a valid TIMEOUT
> structure as a sleazy delay function. Inexcusably lame.  Reason: The
> select() function is intended as a network function, not a general
> purpose timer.  Alternative: Use a legitimate system timer service.

As I mentioned before, and nobody responded... UNIX does have a high
granularity delay function -- usleep().  I also mentioned that it
didn't seem all that accurate when I experimented with it about five
or six years ago, and that select() appeared to be a better
alternative at the time.
 
> 23) select(). Self abusively lame.
 
> Reason: Consider the steps involved in using select(). You need to
> use the macros to clear the 3 fd_sets, then set the appropriate
> fd_sets for each socket, then set the timer, then call
> select(). Then after select() returns with the number of sockets
> that have done something, you need to go through all the fd_sets and
> all the sockets using the macros to find the event that occurred,
> and even then the (lack of) resolution is such you need to infer the
> event from the current socket state.

The fd_sets are bitstrings.  With 1024 file descriptors (for example)
that is 128 bytes per set.  To clear 384 bytes, and to check the bits
on 384 bytes is hardly CPU intensive.

If it is so much more efficient to loop through all the descriptors
yourself with send() and recv(), then wouldn't we be doing that
instead?

_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev



More information about the mud-dev-archive mailing list