event = require "event"
function evthandler_modem_message(msgtype, laddr, raddr, port, dist, ...)
print (...)
end
event.listen("modem_message", evthandler_modem_message);
You may want to check the event library documentation at http://ocdoc.cil.li/api:event
You will need to tell the modem to listen on a specifc port, though, no getting around that. You can put that into a program of its own, and even make it run that program when it boots the computer.
Finally
component = require "component"
modem = component.modem
-- process parameters to a single string
text = table.concat (...