in reply to Socket dilemma - sending EOF

Have you tried doing the following?
#Before writting on the socket $sock->autoflush(); # so output gets there right away

#when writting $data to the socket print $sock $data . "\015\012";

#when done writting to the socket close($sock);

Hope that helps :)