Nice job, did you use mine as a guide? It looks the same. :P
http://www.hawkee.com/snippet/7973/
Might I suggest that you change this
sockwrite -n $sockname Connection: Keep-Alive
to
sockwrite -n $sockname Connection: Close
The reason being is that if you use Keep-Alive then the socket just stays open after the info is received and just stays open. When you use Close instead, it will close the socket immediately after the information is received.