On Fri, 28 Jun 1996, Mud Admin wrote: > if (percent > prob) { > SET_BIT(PLR_FLAGS(ch), PLR_DELETED); > send_to_char("You have suffered permenent death!\r\n", ch); > send_to_char("The next time you enter the Empire, it will be with > a new character.\r\n", ch); > sprintf(buf, "%s (lev %d) has died for real.", GET_NAME(ch), > GET_LEVEL(ch)); > mudlog(buf, NRM, LVL_GOD, TRUE); > close_socket(ch->desc); > } > When I die with a test character and MAKE the con check it works just > fine. However, now when I am dying...before it even gives me the "Your > dead...Sorry!" message, it says "Connection closed by forigen host." But > my character gets the deleted flag set. > Q: Why does it say 'Connection closed by foreign host' and not display the 'byebye, you're leaving' message when I do something like: send_to_char("Bye bye. Come back soon, ya hear?", ch); close_socket(ch-desc); A: The close_socket immediately dispatches/closes the connection, while send_to_char puts the message on the output queue to be dispatched next game_loop cycle. Therefore, the socket is gone. On some systems, this (old linux) this can even cause a infinite loop attempting to write to a closed socket (bad, took an hour to debug). The proper way of doing this and other "Byebye" messages is to set the CON state of the player to CLOSE. This will then cycle to the next game_loop, dispatch the output queues (therefore sending the byebye message) and then close the socket. Further note, I have been getting some problems with this in that it'll only send approximately 40 characters and no escape codes. Sending more than ~40 characters or escape codes (like the clear screen sequence) will crash the bin/circle process reporting a problem similar to writing to a closed socket. -- Billy H. Chan bhchan@po.eecs.berkeley.edu bhchan@csua.berkeley.edu CogSci/CompSci http://www.csua.berkeley.edu/~bhchan ResumeInside
This archive was generated by hypermail 2b30 : 12/18/00 PST