I can always take an example from the metaserver communication in AIDO.
void read_callback( ... ) { while( mixed msg = protocol_parser->feed( data ) ) process_async_msg( msg ); }
mixed do_command( ... ) { fd->write( encode_command( command ) ); while( mixed msg = protocol_parser->feed( fd->read( 2048, 1 ) ) ) if( msg->type == REPLY ) return msg->payload; else process_async_msg( msg ); }
/ Per Hedbor ()
Previous text:
2003-03-19 15:52: Subject: I/O callbacks in blocking mode
No, you've showed that. But I think calling read() when there's a read callback installed is, or perhaps you can show legitimate situations for that too? (I don't count the read call in __stdio_read_callback now; that one ought to be done away with completely.)
/ Martin Stjernholm, Roxen IS