socket question

maximilianscherr MaximilianScherr at T-Online.de
Sun Jan 20 12:17:01 EST 2002


i use an uo emu server, which can accept connections from a special 
port and run an internal script. the port is 5005, the script looks 
like this:

use os;
use uo;

program uoana(connection)
  var event;
  var command;
  var onlinechs;
  var sysload;
  var mobiles;
  var items;
  var bytessent;
  var bytesreceived;
  var uptime;
  var chserial;
  while (connection)
    event := wait_for_event(10); <- waits 10 seconds for connection(s)
    if (event)
      command := event.value[1]; <- gets the first entry in an array
      if (command = "info")
        onlinechs := EnumerateOnlineCharacters().size();
        sysload := polcore().sysload;
        mobiles := polcore().mobilecount;
        items := polcore().itemcount;
        bytessent := polcore().bytes_sent;
        bytesreceived := polcore().bytes_received;
        uptime := polcore().uptime;
        connection.transmit({onlinechs, sysload, mobiles, items, 
bytessent, bytesreceived, uptime}); <- sends back the info!
      endif
      if (command = "setpermitted")
        chserial := CInt(event.value[2]);
        foreach ch in EnumerateOnlineCharacters()
          if (ch.serial = chserial)
            SetObjProperty(ch, "permitted", 1);
          endif
        endforeach
        connection.transmit("setpermitted");
      endif
    endif
  endwhile
  unload_scripts("uoana");
endprogram

so now i don't know how i can send and receive this data with the 
socket mdule. can anyone give me an example?

Thanks,

Max





More information about the Python-list mailing list