/// <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(SocketState dest) { uint total_sent = 0; try { if (AvailableData == 0) { ReadRaw(); } while (AvailableData > 0) { uint sent = dest.WriteBinary(SocketBuffer, BufferPosition, AvailableData); if (sent < AvailableData) { throw new IoBroken(); } total_sent += sent; ReadRaw(); } } catch (SocketException) { /* ignore */ } return(total_sent); }
/// <summary> /// Tunnel a HTTP-chunked blob of data /// </summary> /// <param name="dest">The destination socket</param> /// <remarks> /// The tunneling stops when the last chunk, identified by a /// size of 0, arrives. The optional trailing entities are also /// transmitted (but otherwise ignored). /// </remarks> public void TunnelChunkedDataTo(SocketState dest) { TunnelChunkedDataTo(dest, (buffer, offset, size) => { if (dest.WriteBinary(buffer, offset, size) < size) { throw new IoBroken(); } }); }
/// <summary> /// Read <c>nb_bytes</c> bytes from the socket, /// and send it to the destination socket /// </summary> /// <returns>The number of bytes sent</returns> public uint TunnelDataTo(SocketState dest, uint nb_bytes) { return(TunnelDataTo((b, o, s) => { if (dest.WriteBinary(b, o, s) < s) { throw new IoBroken(); } }, nb_bytes)); }
/// <summary> /// Message packet handler for tunneling data from BrowserSocket to RemoteSocket /// </summary> protected void TunnelRemoteSocket(byte[] msg, uint position, uint to_send) { if (to_send == 0) { return; } if (RemoteSocket.WriteBinary(msg, position, to_send) < to_send) { throw new IoBroken(); } }
/// <summary> /// Read <c>nb_bytes</c> bytes from the socket, /// and send it to the destination socket /// </summary> /// <returns>The number of bytes sent</returns> public uint TunnelDataTo(SocketState dest, uint nb_bytes) { return TunnelDataTo((b, o, s) => { if (dest.WriteBinary(b, o, s) < s) { throw new IoBroken(); } }, nb_bytes); }
/// <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(SocketState dest) { uint total_sent = 0; try { if (AvailableData == 0) { ReadRaw(); } while (AvailableData > 0) { uint sent = dest.WriteBinary(SocketBuffer, BufferPosition, AvailableData); if (sent < AvailableData) { throw new IoBroken(); } total_sent += sent; ReadRaw(); } } catch (SocketException) { /* ignore */ } return total_sent; }
/// <summary> /// Tunnel a HTTP-chunked blob of data /// </summary> /// <param name="dest">The destination socket</param> /// <remarks> /// The tunneling stops when the last chunk, identified by a /// size of 0, arrives. The optional trailing entities are also /// transmitted (but otherwise ignored). /// </remarks> public void TunnelChunkedDataTo(SocketState dest) { TunnelChunkedDataTo(dest, (buffer, offset, size) => { if (dest.WriteBinary(buffer, offset, size) < size) { throw new IoBroken(); } }); }