hi,
can someone make up for the lack of documentation and explain how to use Protocols.TELNET.Readline?
i have extracted some ideas from the roxen hilfe protocol implementation and condensed it to the example below.
the main thing i am wondering about is this init loop, it does not seem to work without.
#!/usr/bin/pike
object readln;
void got_connection (mixed port) { object in; if(port) in=port->accept(); if (!in) { werror("Couldn't accept connection"); return; } werror("port is open\n"); readln = Protocols.TELNET.Readline(in, got_user_line, 0, 0, 0); init(); }
int n;
static void init( ) { if( readln->readline ) { readln->readline->write("Welcome\n", 1); return; } n++; if( n < 100 ) call_out( init, 0.1 ); else { readln->message("Failed to set up terminal.\n"); } }
void got_user_line( mixed q, string line ) { readln->readline->write("> "); write("input: %O, %s\n", q, line); }
int main() { object port=Stdio.Port(); port->bind(3333,got_connection,"localhost"); port->set_id(port); return -1; }
pike-devel@lists.lysator.liu.se