Error on socket send

Hmm… not sure. One thing that looks wrong is buffer.GetTypeSize(). Did you mean buffer.TotalSize() ?

As far as the failed sending, your best bet would be step into socket code and see what error codes are returned.