[MUD-Dev] [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine
Todd Lair
tlair at mailzone.com
Fri Jul 17 20:37:18 CEST 1998
Ok, I know it's been stated that we are allowed to discuss implementations of what we
want to code, and because I've seen virtually no discussion of this type, I'm still a little
leery of whether what follows is a-ok. If, by any chance, you think such C++/Unix specific
topics are out of order here, please hit your delete key now. I, being a big wus, would
much prefer that than someone's atomic flame thrower, or *cringe* a message from the list
owner. I'll regard no response as an indication that I was out of line, and will continue
trying to figure it out myself.
Anyway, on with my question. I have recently written my event engine, and I'm trying to
get optimal player socket polling using this engine. There are two different types of
socket objects, a master, and a socket. A master has an event associated with it, that
when the event is ripened, it polls it's input. Successful poll indicates that there is a new
connection, and a player object should be allocated. A socket type is associated with a
little more of an event in that its input, output, and exception status is polled to indicate
player input, output or exception on that socket. The socket class is inherited from the
player class.
Now, as far as the polling for both types of sockets, I'm wondering if there isn't a more
efficient way than what I'm doing. What I'm doing is using select, however, I'm only
setting the single bit for the the descriptor in question for all three fd_sets. This seems
like a big mistake to me, since I imagine, as the descriptors get larger in number, that the
select call has to see if each bit is set for the lower descriptor numbers till it gets to the
single set one.
I was wondering if I should just call recv, with the peek option (maybe with the input
buffer) set as a single byte, to see if the socket has something to read or is in exception.
Would this be the optimal way to do it, or is select fine? Also, do I have to check on the
output status? Is there a time when a socket is not writable? What are return values of
recv that would indicate exceptions, or rather what should I be on the lookout for with
respect to errno's value?
I look forward to hearing any thoughts regarding the above, and thanks in advance!
Todd
More information about the mud-dev-archive
mailing list