envio cadena texto del lado del cliente y envio de imagenes lado servidor

Good evening, I’m new here, what I do is when I press one CheckButton sending a string of concatenated text with a button, this button sends the information to the string I want to show in another phone that handles like “server” and this sending you pictures to phones that are on the same network. Thank You

client

local socket = require “socket”

local address, port = “localhost”, 12345

function sendUdpMsg()

udp = socket.udp()

udp:settimeout(0)

udp:setpeername(address, port)

local dg = “hola”

local snd = udp:send(dg)

print("Sent: " … dg)

end

sendUdpMsg()

local widget = require( “widget” )

–local logo = display.newImageRect(“logo.jpg”, 320, 480)

–logo.x = display.contentCenterX

–logo.y = display.contentCenterY

– Handle press events for the buttons

– Create a group for the radio button set

local radioGroup = display.newGroup()

local texto=display.newText(“Puntuacion 1”, 150,135,native.systemFont,25)

local function onSwitchPress( event )

    local switch = event.target

    print( “ID '”…switch.id…"’ is on: "…tostring(1) )

end

–texto:setTextColor(0,0,0)

– Create two associated radio buttons (inserted into the same display group)

local boton1 = widget.newSwitch

{

    left = 20,

    top = 120,

    style = “radio”,

    id = “boton1”,

    onPress = onSwitchPress

}

radioGroup:insert( boton1)

local texto=display.newText(“Puntuacion 2”, 150,185,native.systemFont,25)

local function onSwitchPress( event )

    local switch = event.target

    print( “Switch with ID '”…switch.id…"’ is on: "…tostring(2) )

end

local boton2 = widget.newSwitch

{

    left = 20,

    top = 170,

    style = “radio”,

    id = “boton2”,

    onPress = onSwitchPress

}

radioGroup:insert( boton2 )

local texto=display.newText(“Puntuacion 3”, 150,235,native.systemFont,25)

local function onSwitchPress( event )

    local switch = event.target

    print( “Switch with ID '”…switch.id…"’ is on: "…tostring(3) )

end

local boton3 = widget.newSwitch

{

    left = 20,

    top = 220,

    style = “radio”,

    id = “boton3”,

    onPress = onSwitchPress

}

radioGroup:insert( boton3 )

local texto=display.newText(“Puntuacion 4”, 150,285,native.systemFont,25)

local function onSwitchPress( event )

    local switch = event.target

    print( “Switch with ID '”…switch.id…"’ is on: "…tostring(4) )

end

local boton4 = widget.newSwitch

{

    left = 20,

    top = 270,

    style = “radio”,

    id = “boton4”,

    onPress = onSwitchPress

}

radioGroup:insert( boton4 )

local texto=display.newText(“Puntuacion 5”, 150,335,native.systemFont,25)

local function onSwitchPress( event )

    local switch = event.target

    print( “Switch with ID '”…switch.id…"’ is on: "…tostring(5) )

end

local boton5 = widget.newSwitch

{

    left = 20,

    top = 320,

    style = “radio”,

    id = “boton5”,

    onPress = onSwitchPress

}

radioGroup:insert( boton5 )

local botonenviar = widget.newButton

{

id = “botonenviar”,

defaultFile = “boton.png”,

String mensaje="Calificacion ";

        if (boton1.isSelected()) {

            mensaje=mensaje+" 1";

        }

        if (boton2.isSelected()) {

            mensaje=mensaje+"2 ";

        }

        if (boton3.isSelected()) {

            mensaje=mensaje+"3 ";

        }

        if (boton4.isSelected()) {

            mensaje=mensaje+"4 ";

        }

        if (boton5.isSelected()) {

            mensaje=mensaje+"5 ";

        }

        etiResultado.setText(mensaje);}

}

botonenviar:addEventListener(“tap”, enviar)

server

local socket = require “socket”

– begin

local udp = socket.udp()

udp:settimeout(0)

udp:setsockname(’*’, 12345)

local data, msg_or_ip, port_or_nil

local function revieveUdpMsg(event)

print(“Ready to recieve…”)

local running = true

while running do

data, msg_or_ip, port_or_nil = udp:receivefrom()

if data ~= nil then

print("Recieved: " … data)

running = false

print("Server paused ")

timer.performWithDelay( 3000, revieveUdpMsg )

elseif msg_or_ip ~= ‘timeout’ then

error("Unknown network error: "…tostring(msg))

end

socket.sleep(0.01)

end

end

timer.performWithDelay( 3000, revieveUdpMsg )