private void RecvAll(Socket socket, byte[] buffer, int offset, int size)
{
int recv = 0;
int total_recv = 0;
int end = offset + size;
while (offset < end)
{
try
{
recv = socket.Receive(buffer, offset, (size - total_recv), 0);
total_recv += recv;
offset += recv;
}
catch (SocketException e)
{
throw new TransportException("Error receiving from Socket");
}
}
}