Screenary.TransportClient.SendAll C# (CSharp) Method

SendAll() private method

private SendAll ( Socket socket, byte buffer, int offset, int size ) : void
socket Socket
buffer byte
offset int
size int
return void
        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");
                }
            }
        }