> Unfortunately, since they are coming in through a socket and not actual
> telnet/ssh I don't think $fp=fopen("/dev/stdin", "r"); works? Isn't that
> only for terminal based input?
>
> Donald Myers

Have you tried it? Every process will have access to its own STDIN and
STDOUT.

since your MUD server runs constantly you will have a stateful environment,
so keeping track of who's who should be possible.

This is purely guess work :-) but I think it should work. Perhaps there's
some way to fork?? I dunno. STDIN is there. I guess it's just a matter
figuring out how to access it.

Good luck! Let me know how it goes. If you want to send me some source code
off-list I'd be happy to give it a whirl. It might be better to solve
off-list and post the solution on-list since the code is probably huge.

Jim Grill

>
>
> on 9/2/04 10:31 AM, Jim Grill at [EMAIL PROTECTED] wrote:
>
> >> Hello, I have been banging my head trying to figure out how to design a
> > MUD
> >> Server using PHP-CLI as the server and PHP-CLI as the "command"
language.
> >> (telnet front end at this point)
> >>
> >> but....
> >>
> >> The real problem is full interaction with the user in those external
> >> commands (php-cli scripts) to send and read data.
> >>
> >>
> >> A. How do I create a input method to connect the external PHP script to
> > the
> >> Server's Socket?
> >>
> >> B. Since the PHP-CLI script never ends how can I send the first echo
"You
> >> have..."?
> >> D Myers
> >>
> >
> > I hope I'm understanding what you're asking. If you need to interact
with
> > the user via stdin you can use this function to capture user input:
> >
> > function read()
> > {
> >   $fp=fopen("/dev/stdin", "r");
> >   $input=fgets($fp, 255);
> >   fclose($fp);
> >
> >   return $input;
> > }
> >
> > Your code flow could look something like:
> > <?php
> > do {
> >   print "what's your name?\n";
> >   $name = read();
> > } while (empty($name));
> >
> > print "Hello $name!\n";
> > sleep(1);
> >
> > do {
> >   print "What is your jedi name?\n";
> >   $jediName = read();
> > } while (empty($jediName));
> >
> > print "Hello $name AKA $jediName\n\n";
> >
> > function read()
> > {
> >   $fp=fopen("/dev/stdin", "r");
> >   $input=fgets($fp, 255);
> >   fclose($fp);
> >
> >   return trim($input);
> > }
> > ?>
> >
> > I hope that gets you started in the right direction. Sounds like a fun
> > project.
> >
> > Jim Grill
> > Web-1 Hosting, LP
> > http://www.web-1hosting.net
> >
> >
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to