All pastes #607833 Raw Edit

Anonymous

public lua v1 · immutable
·published 2007-07-07 22:33 UTC
rendered paste body
--Network Music Player Daemon alpha by Hexxeh--What port do we listen for requests on? Default is fine, don't change unless you've got a good reasonPORT = 2222-----------------------------------------DON'T EDIT BELOW HERE!---------------------------------------require("socket")print("Network Music Player Daemon Started")nmpd = socket.tcp()nmpd:bind("*", PORT)nmpd:listen()recvt = {}connections = 0;table.insert(recvt,nmpd)while true do	local reading,writing,err = socket.select(recvt,nil)	if reading[nmpd] then		local connected = nmpd:accept()		table.insert(recvt,connected)		connected:send("HELLO\n")		connections = connections + 1		print("NMPD: New client connected. Total: ".. connections ..".")	else		for k,v in pairs(reading) do			local message,err = k:receieve("*l")			if err == nil then				if message == "BYE\n" then					connections = connections - 1					connected:close();				elseif string.sub(1,4,message) == "PLAY" then					PlaySong()				elseif string.sub(1,4,message) == "STOP" then					StopSong()				elseif string.sub(1,5,message) == "PAUSE" then					PauseSong()				end			end		end	endendfunction PlaySong()	print("NMPD: PlaySong not yet implemented")endfunction StopSong()	print("NMPD: StopSong not yet implemented")endfunction PauseSong()	print("NMPD: PauseSong not yet implemented")end