P. Fishwick Feb 2008 Re-purposed from Linden Lab examples -------------------------------------------------- THIS IS THE CODE THAT GOES INTO A SECOND LIFE PRIM -------------------------------------------------- // XML-RPC example key gChannel; // my llRemoteData channel DEBUG(list out) { // output debug info llSay(0, llList2CSV(out)); } integer factorial( integer n) { if (n == 0 || n == 1) return 1; else { integer k = n - 1; return n * factorial (k); } } default { // initialize XML-RPC on_rez(integer num_count) { llOpenRemoteDataChannel(); // create an XML-RPC channel // this will raise remote_data event REMOTE_DATA_CHANNEL when created } remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval) { if (type == REMOTE_DATA_CHANNEL) { // channel created DEBUG(["Channel opened", "REMOTE_DATA_CHANNEL", channel, message_id, sender, ival, sval]); gChannel = channel; llSay(0, "Ready to receive requests on channel \"" + (string)channel +"\""); state go; // start handling requests } else DEBUG(["Unexpected event type", type, channel, message_id, sender, ival, sval]); } } state go { // handle requests remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval) { if (type == REMOTE_DATA_REQUEST) { // handle requests sent to us DEBUG(["Request received", "REMOTE_DATA_REQUEST", channel, message_id, sender, ival, sval]); // handle request integer num = (integer) sval; string fact_result = (string) factorial(num); llRemoteDataReply(channel,message_id,fact_result,1); } else DEBUG(["Unexpected event type:", type, channel, message_id, sender, ival, sval]); } state_exit() { llCloseRemoteDataChannel(gChannel); // clean up when you no longer want to handle requests } } ------------------------------------------ THIS IS THE CODE THAT GOES ON YOUR SERVER: ------------------------------------------ #!/usr/local/bin/php PHP XMLRPC Test llRemoteDataChannel'.$ channel.'IntValue'.$i ntval.'StringValue'.$ strval.''; $response = $client->send( $content, 60, 'http' ); $v = php_xmlrpc_decode($response->value()); printf("The factorial of %s is %s",$strval,$v["StringValue"]); // print($response->serialize()); return true; } send($channelid,0,$NUM); ?>