• Product Bundles

    DevCraft

    All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:

    • NEW: Design Kits for Figma
    • Online Training
    • Document Processing Library
    • Embedded Reporting for web and desktop
    Web
    Kendo UI UI for jQuery UI for Angular UI for React UI for Vue UI for ASP.NET AJAX UI for ASP.NET MVC UI for ASP.NET Core UI for Blazor UI for Silverlight UI for PHP UI for JSP
    Mobile
    UI for .NET MAUI UI for Xamarin
    Document Management
    Telerik Document Processing
    Desktop
    UI for .NET MAUI UI for WinUI UI for WinForms UI for WPF UI for UWP
    Reporting & Mocking
    Telerik Reporting Telerik Report Server Telerik JustMock
    Automated Testing
    Test Studio Test Studio Dev Edition
    CMS
    Sitefinity
    UI/UX Design
    Unite UX
    Debugging
    Fiddler Fiddler Everywhere Fiddler Classic Fiddler Jam FiddlerCap FiddlerCore
    Extended Reality
    UI for Unity XR
    Free Tools
    JustAssembly JustDecompile VB.NET to C# Converter Testing Framework
    View all products
  • Overview
    • jQuery
    • Angular
    • React
    • Vue
  • Demos
    • What's New
    • Roadmap
    • Release History
  • Docs & Support
  • Pricing
  • Search
  • Shopping cart
    • Account Overview
    • Your Licenses
    • Support Center
    • Forum Profile
    • Payment Methods
    • Edit Profile
    • Log out
  • Login
  • Contact Us
  • Try now

Class BasePipe

Abstract base class for the ClientPipe and ServerPipe classes. A Pipe represents a connection to either the client or the server, optionally encrypted using SSL/TLS.

Inheritance
System.Object
BasePipe
ClientPipe
ServerPipe
Namespace: Fiddler
Assembly: FiddlerCore.dll

Syntax

public abstract class BasePipe : Object

Constructors

BasePipe(Socket, String)

Create a new pipe, an enhanced wrapper around a socket

Declaration
public BasePipe(Socket oSocket, string sName)
Parameters
System.Net.Sockets.Socket oSocket

Socket which this pipe wraps

System.String sName

Identification string used for debugging purposes

Fields

_baseSocket

The base socket wrapped in this pipe

Declaration
protected Socket _baseSocket
Field Value
System.Net.Sockets.Socket

_httpsStream

The HTTPS stream wrapped around the base socket (SslStream on Windows/Linux or BcTlsConnection.AuthenticatedStream on MacOS)

Declaration
protected Stream _httpsStream
Field Value
System.IO.Stream

_sPipeName

The display name of this Pipe. Use strings starting with "ClientPipe" for client pipes and "ServerPipe" for server pipes.

Declaration
protected string _sPipeName
Field Value
System.String

clientPipeName

The name that should be used for client pipes

Declaration
public const string clientPipeName = "ClientPipe"
Field Value
System.String

iUseCount

The number of times that this Pipe has been used

Declaration
protected uint iUseCount
Field Value
System.UInt32

SendLock

Used to ensure that send operations on the pipe are queued

Declaration
protected readonly SemaphoreSlim SendLock
Field Value
System.Threading.SemaphoreSlim

serverPipeName

The name that should be used for client pipes

Declaration
public const string serverPipeName = "ServerPipe"
Field Value
System.String

Properties

Address

Returns the remote address to which this Pipe is connected, or 0.0.0.0 on error.

Declaration
public IPAddress Address { get; }
Property Value
System.Net.IPAddress

bIsSecured

Returns a bool indicating if the socket in this Pipe is CURRENTLY connected and wrapped in a SecureStream

Declaration
public bool bIsSecured { get; }
Property Value
System.Boolean

Connected

Return the Connected status of the base socket. WARNING: This doesn't work as you might expect; you can see Connected == false when a READ timed out but a WRITE will succeed.

Declaration
public bool Connected { get; }
Property Value
System.Boolean

IsHTTP2

Returns true if the SslStream's negotiated protocol is h2

Declaration
public bool IsHTTP2 { get; }
Property Value
System.Boolean

LocalPort

Return the Local Port to which the base socket is attached. Note: May return a misleading port if the ISA Firewall Client is in use.

Declaration
public int LocalPort { get; }
Property Value
System.Int32

Port

Return the Remote Port to which this socket is attached.

Declaration
public int Port { get; }
Property Value
System.Int32

SecureProtocol

Returns the SSL/TLS protocol securing this connection

Declaration
public SslProtocols SecureProtocol { get; }
Property Value
System.Security.Authentication.SslProtocols

TransmitDelay

Gets or sets the transmission delay on this Pipe, used for performance simulation purposes.

Declaration
public int TransmitDelay { get; set; }
Property Value
System.Int32

Methods

EndAsync(ErrorCode, String)

Shutdown and close the socket inside this pipe. Eats exceptions.

Declaration
public Task EndAsync(ErrorCode errorCode, string debugData = "")
Parameters
Http2.ErrorCode errorCode

System.String debugData

Returns
System.Threading.Tasks.Task

EndWithRST()

Abruptly closes the socket by sending a RST packet

Declaration
public void EndWithRST()

GetRawSocket()

Return the raw socket this pipe wraps. Avoid calling this method if at all possible.

Declaration
public Socket GetRawSocket()
Returns
System.Net.Sockets.Socket

The Socket object this Pipe wraps.

HasDataAvailable()

Poll the underlying socket for readable data (or closure/errors)

Declaration
public virtual bool HasDataAvailable()
Returns
System.Boolean

TRUE if this Pipe requires attention

InitializeHTTP2PipeAsync()

HTTP2 connections must be initialized by receiving and sending specific headers and settings frames. This happens only once per established connection.

Declaration
public Task InitializeHTTP2PipeAsync()
Returns
System.Threading.Tasks.Task

SendAsync(Byte[])

Sends a byte array through this pipe

Declaration
public Task SendAsync(byte[] oBytes)
Parameters
System.Byte[] oBytes

The bytes

Returns
System.Threading.Tasks.Task

SendDataAsync(Byte[], Int32, Int32, UInt32, Boolean)

Send a byte array through this pipe, taking into account the protocol used (http/1.1 or http/2)

Declaration
public Task<int> SendDataAsync(byte[] arrData, int responseOffset, int responseLength, uint streamId, bool final = true)
Parameters
System.Byte[] arrData

Array to send

System.Int32 responseOffset

The data offset in the array to send

System.Int32 responseLength

How many bytes of the array to send

System.UInt32 streamId

The stream ID - omitted for http/1.1 pipes

System.Boolean final

True if this is the final data(body) to send through the pipe - not used for http/1.1 pipes

Returns
System.Threading.Tasks.Task<System.Int32>

The size of the transferred data over the network in bytes

SendRequestHeadersAsync(HTTPRequestHeaders, UInt32, Boolean, String, Nullable<Boolean>)

Send HTTP request headers through the pipe with additional options

Declaration
public Task<int> SendRequestHeadersAsync(HTTPRequestHeaders headers, uint newStreamId, bool includeProtocolInPath, string sVerbLineHost, Nullable<bool> hasBody)
Parameters
HTTPRequestHeaders headers

request headers

System.UInt32 newStreamId

the stream ID to use when sending HTTP2 headers

System.Boolean includeProtocolInPath

TRUE if the SCHEME and HOST should be included in the HTTP REQUEST LINE

System.String sVerbLineHost

the host to use in the HTTP REQUEST LINE

System.Nullable<System.Boolean> hasBody

HTTP2 only - True if there is a body ready to send after the headers

Returns
System.Threading.Tasks.Task<System.Int32>

The size of the transferred data over the network in bytes

SendResponseHeadersAsync(HTTPResponseHeaders, Nullable<UInt32>, Nullable<Boolean>, Boolean, Boolean)

Send HTTP headers through a pipe

Declaration
public Task<int> SendResponseHeadersAsync(HTTPResponseHeaders headers, Nullable<uint> streamId, Nullable<bool> hasBody, bool ignoreTranslationErrors = false, bool trailersOnly = false)
Parameters
HTTPResponseHeaders headers

response headers

System.Nullable<System.UInt32> streamId

HTTP2 only - the stream ID

System.Nullable<System.Boolean> hasBody

HTTP2 only - True if there is a body ready to send after the headers

System.Boolean ignoreTranslationErrors

Ignore possible errors that occur if headers are translated from HTTP/1.1 to HTTP/2

System.Boolean trailersOnly

Set to true only if this is a GRPC response that does not have response headers (e.g. error response)

Returns
System.Threading.Tasks.Task<System.Int32>

The size of the transferred data over the network in bytes

UseCustomTlsProvider()

On Mac OS a SslStream cannot authenticate as a TLS server, so we need to use another TLS stream implementation. On Mac OS, SslStream does not support TLS 1.3 as client, so we need to use another TLS stream implementation.

Declaration
protected bool UseCustomTlsProvider()
Returns
System.Boolean

True if a custom stream should be used instead of the .NET SslStream for TLS connections.

Events

OnConnectionClosed

Raised when the connection is closed

Declaration
public event EventHandler OnConnectionClosed
Event Type
System.EventHandler

Getting Started
  • Try Now
Community
  • Forums
  • Blogs
  • Feedback Portal

Copyright © 2019 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.