Here´s some code:
First the connection to server and retrieval of audiostream.
conn3 = net.createConnection(net.TCP, 10)
conn3:connect(4051, serverip)
conn3:on("receive", function(conn3, audio) buffer=audio end)
Then the PCM part:
drv = pcm.new(pcm.SD, 6)
drv:on("data", buffer)
drv:play(pcm.RATE_8K)
The buffer variable always contain the audio data and can be printed, but not played by PCM module.
If I write the stream to disk, then it can be played by drv:on and with the complement of file.open() and file.read(). However this requires that the file will be closed after writing before reading and that´s not really suitable for me due to delay and loss.