in reply to html2doc server connection dies early
It could well be an illusion when yuo said that the connection died early. I noticed that you didn't binmode() the socket - $client. When you read the content of the word document, you did binmode() the file handler, but then you print the same content to a socket without binmode(). That is not correct.
My guess is that the content get cut short because there was no binmode(), which then made you thought that the connection died.