[MUD-Dev] Modular Design Issues RFC

Scion Altera keeler at teleport.com
Thu Feb 15 23:11:43 CET 2001


Thursday, February 15, 2001, 3:12:42 AM, Ryan Rhodes wrote:

RR> The only way to generate a Connection Closed exception for thread
RR> death is to be constantly blocking for input.  Java doesn't allow
RR> you to stop blocking once you have started, nor does it provide any sort of
RR> asynchronous method to read input.  You can check for the ammount of
RR> input available before you read it, reading in just enough to prevent
RR> blocking, but then you can't capture link death.

That is not entirely true. You can poll connections in Java (checking
whether input is available or not), and it is true that you cannot
tell if a connection is dead by reading from it. However, if you try
to write to a connection that is dead, you get an IOException thrown.

The Java MUD development framework I'm currently working on uses this.
There is one "listener" thread that blocks at accept() and waits for
connections, then passes them to another single thread that pulses
every 1/10th of a second reading for input. It doesn't bother checking
for disconnections because it can't (*smirk*) do so.. it just catches
the IOException when it tries to write something to the socket and
extracts the character cleanly from there.

-- Scion

"Close only counts in hopscotch and hand grenades." -- Unknown

-- keeler at teleport.com -- peter.keeler at brokat.com -- ICQ: 1824934 --


_______________________________________________
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