How to use OSC

I now this sounds a little weird because I have made an AI already but I have been trying to work out OSC for over 2 hours now so can someone please help and paste example code at bottom

@joaquin Here’s an example. Put this code on both devices and run it. It will show the IP address of the device it’s running on. Put the IP address in the code below for the other devices so each device knows it’s IP address and the other devices address. Then run this on both devices, move your finger around and the sprite will move on the other device.

PS. There is also some code on the forum where I can transfer projects from one iPad to the other. I haven’t found it yet.

function setup()
    host = osc.start()  -- address of this ipad
    print(host)
    osc.host = "192.168.254.15"  -- put address of other ipad here
    x,y=0,0      
end

function draw()
    background(0)
    sprite("Planet Cute:Character Horn Girl",x,y)
end

function osc.listen(address, ...)
    arg={...}
    x=arg[1]
    y=arg[2]
end

function touched(t)
    if t.state==MOVING then
        osc.send("/",t.x,t.y)
    end
end

@joaquin Here’s a link to code I wrote to transfer project from one iPad to another.

https://codea.io/talk/discussion/9464/the-new-osc-capability-in-2-7-is-wonderful#latest

Thanks

@dave1707 Do you know if you can have only one connection (osc.host) or can you have multiple OSCs running?

Edit: I can think of switching to the needed port every time before sending an event, but I’m sure there was another way of doing so, can’t find right now.