I don't mean to ask a stupid question, but your code above is consistent with the output you're wanting.
should be sent to the client followed by a null byte. My question is this: Are you certain
has the value you expect? Are you certain that the client is getting an empty message (a single null byte)?