--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("-------------------------------------------")print("----Network Music Player Daemon Started----")print("-------------------------------------------")print("-------------------------- Alpha Version --")print("-------------------------------------------")nmpd = socket.tcp()nmpd:bind("*", PORT)nmpd:listen()recvt = {}connections = 0;table.insert(recvt,nmpd)function printerror(text) print("NMPD: "..text)endfunction PlaySong() printerror("PlaySong not yet implemented")endfunction StopSong() printerror("StopSong not yet implemented")endfunction PauseSong() printerror("PauseSong not yet implemented")endwhile 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 printerror("New client connected. Total: ".. connections ..".") else for k,v in pairs(reading) do local message,err = v:receive("*l") if err == nil then if message == "BYE\n" then connections = connections - 1 v:close() elseif string.sub(message,1,4) == "PLAY" then PlaySong() v:send("ACKPLAY\n") elseif string.sub(message,1,4) == "STOP" then StopSong() v:send("ACKSTOP\n") elseif string.sub(message,1,5) == "PAUSE" then PauseSong() v:send("ACKPAUSE\n") else printerror("Unrecognised command from client") end else printerror("Socket error! (".. err ..")") end end endend