A quick hint:

Use the socket tutorial of the help file: /help $sock and write the %temp buffer to a file during the read loop.