--[[
netlib example
by youresam
]]

dofile("netlib.lua") -- netlib

Wlan.init()
print("Connecting to "..Wlan.getConnectionConfigs()[1].."...")
Wlan.useConnectionConfig(1)

print("Connecting to netlib server...")
netconnect() -- connect to netlib server

print("Setting up AMW for 'netlibtest' (wont do anything in this example..)")
netreg("netlibtest")

print("Sending 'helloworld' to 'netlibtest'")
netsend("netlibtest","helloworld","w") -- id:netlibtest data:helloworld mode:write

print("Getting 'netlibtest'...(Press start to quit)")
netget("netlibtest")
while true do
	netrecv() --recieve all incoming data
	buffer = netvalue("netlibtest") --what is the value of the id 'netlibtest'?
		if buffer ~= "" then --if it exists...
			print(buffer)
			break
		end
	if Controls.read():start() then break end
end

netunreg("netlibtest") --ALWAYS unregister a variable when your done

netclose() --close the netlib connection

Wlan.term()

print("Program finished, hold start to exit.")



