Heya. I'm currently in the process of writing a totally web-based client in PHP for my MUD. Such a thing is good in situations where even java telnet isn't an option, such as if you're behind a tight firewall (like I am at work hehe). Maintaining a constant open connection in PHP is simply not possible due to the way it's setup, as I'm sure you already know (took me awhile to figure that out for myself though).
So here's the premise: Make the initial connection on a special port using fsockopen, show the greeting screen, create the descriptor, then the MUD severs the connection, but without destroying the descriptor. The client and MUD will then communicate via input and output files (one acting as user input, the other as output for the client to display to the user). The files are named using the descriptor number and a short, randomly-generated passcode (both of which sent to the client before connection is severed) which serves to prevent accidental re-use of an old file and to deter would-be spammers from hyjacking it.
This premise would require minnimal alteration to the MUD itself with little or no loss of compatability (except maybe MSP or whatever :P), making it suitable for public release when it's finished.
Here's where I'm running into trouble. I close the connection (using closesocket as opposed to the close_socket function), and the descriptor is still there as it should be. Let's call it descriptor 16 (assuming I already have my admin character logged-in descriptor 15). Then, I connect to the MUD via standard telnet. I type 'users' on my admin character? I'm still descriptor 15, but BOTH the php and telnet users are using descriptor 16! When the PHP client connects, it sends 'new' before it's disconnected (just as a debug for now). When the second telnet user connects, it's already at the CON_GET_NEW_NAME section.
I've gone through every applicable line of accept_new, new_descriptor, init_descriptor, and game_loop, but everything I try (moving things around, ifchecks, manipulating the d->descriptor value directly by adding 1 to it for each PHP descriptor there currently is, etc) either causes a crash bug, causes problems in the initial connection such hanging, or has no effect whatsoever. The function (accept) that actually sets the 'desc' variable (which then becomes the integer value for d->descriptor) appears to be some internal compiler function, as I can't find it anywhere in the source. Therefore, I'm completely stumped as to what to do with it. The fact that this FD_SET and &in_set/&out_set/&exec_set stuff totally eludes me probably doesn't help much lol.
Anyways, if you've got any suggestions Nick (or anyone else who got any of this :P), I'm all ears. Anything that wouldn't require re-writing every section that loops through the descriptors (prolly like 90% of the MUD or so) would be extremely helpful =)
So here's the premise: Make the initial connection on a special port using fsockopen, show the greeting screen, create the descriptor, then the MUD severs the connection, but without destroying the descriptor. The client and MUD will then communicate via input and output files (one acting as user input, the other as output for the client to display to the user). The files are named using the descriptor number and a short, randomly-generated passcode (both of which sent to the client before connection is severed) which serves to prevent accidental re-use of an old file and to deter would-be spammers from hyjacking it.
This premise would require minnimal alteration to the MUD itself with little or no loss of compatability (except maybe MSP or whatever :P), making it suitable for public release when it's finished.
Here's where I'm running into trouble. I close the connection (using closesocket as opposed to the close_socket function), and the descriptor is still there as it should be. Let's call it descriptor 16 (assuming I already have my admin character logged-in descriptor 15). Then, I connect to the MUD via standard telnet. I type 'users' on my admin character? I'm still descriptor 15, but BOTH the php and telnet users are using descriptor 16! When the PHP client connects, it sends 'new' before it's disconnected (just as a debug for now). When the second telnet user connects, it's already at the CON_GET_NEW_NAME section.
I've gone through every applicable line of accept_new, new_descriptor, init_descriptor, and game_loop, but everything I try (moving things around, ifchecks, manipulating the d->descriptor value directly by adding 1 to it for each PHP descriptor there currently is, etc) either causes a crash bug, causes problems in the initial connection such hanging, or has no effect whatsoever. The function (accept) that actually sets the 'desc' variable (which then becomes the integer value for d->descriptor) appears to be some internal compiler function, as I can't find it anywhere in the source. Therefore, I'm completely stumped as to what to do with it. The fact that this FD_SET and &in_set/&out_set/&exec_set stuff totally eludes me probably doesn't help much lol.
Anyways, if you've got any suggestions Nick (or anyone else who got any of this :P), I'm all ears. Anything that wouldn't require re-writing every section that loops through the descriptors (prolly like 90% of the MUD or so) would be extremely helpful =)