/// <summary>
/// Transfer data from this socket to the destination socket
/// until this socket closes
/// </summary>
/// <returns>The number of bytes sent</returns>
public uint TunnelDataTo(HttpSocket dest)
{
uint total_sent = 0;
try
{
if (AvailableData == 0)
{
ReadRaw();
}
while (AvailableData > 0)
{
uint sent = dest.WriteBinary(Buffer, BufferPosition,
AvailableData);
if (sent < AvailableData)
{
throw new IoBroken();
}
total_sent += sent;
ReadRaw();
}
}
catch (SocketException) { /* ignore */ }
return(total_sent);
}