private void SendAll(Socket socket, byte[] buffer, int offset, int size)
{
int sent = 0;
int total_sent = 0;
int end = offset + size;
while (offset < end)
{
try
{
sent = socket.Send(buffer, offset, (size - total_sent), 0);
total_sent += sent;
offset += sent;
}
catch (SocketException e)
{
throw new TransportException("Error sending through socket");
}
}
}