Show / Hide Table of Contents

Class SIPTCPChannel

SIP transport for TCP. Note this is also the base class for the SIPTLSChannel. For the TLS channel the TCP base class will accept or connect and then switch to the TLS class to upgrade to an SSL stream.

Inheritance
System.Object
SIPChannel
SIPTCPChannel
SIPTLSChannel
Implements
System.IDisposable
Inherited Members
SIPChannel.logger
SIPChannel.ID
SIPChannel.LocalIPAddresses
SIPChannel.InternetDefaultAddress
SIPChannel.ListeningIPAddress
SIPChannel.Port
SIPChannel.ListeningEndPoint
SIPChannel.ListeningSIPEndPoint
SIPChannel.IsReliable
SIPChannel.IsSecure
SIPChannel.SIPProtocol
SIPChannel.Closed
SIPChannel.SIPMessageReceived
SIPChannel.SIPEncoding
SIPChannel.SIPBodyEncoding
SIPChannel.GetLocalIPAddressForDestination(IPAddress)
SIPChannel.GetContactURI(SIPSchemesEnum, SIPEndPoint)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: SIPSorcery.SIP
Assembly: SIPSorcery.dll
Syntax
public class SIPTCPChannel : SIPChannel, IDisposable

Constructors

| Improve this Doc View Source

SIPTCPChannel(IPAddress, Int32, Boolean)

Declaration
public SIPTCPChannel(IPAddress listenAddress, int listenPort, bool useDualMode = false)
Parameters
Type Name Description
System.Net.IPAddress listenAddress
System.Int32 listenPort
System.Boolean useDualMode
| Improve this Doc View Source

SIPTCPChannel(IPEndPoint, SIPProtocolsEnum, Boolean, Boolean)

Declaration
public SIPTCPChannel(IPEndPoint endPoint, SIPProtocolsEnum protocol, bool canListen = true, bool useDualMode = false)
Parameters
Type Name Description
System.Net.IPEndPoint endPoint
SIPProtocolsEnum protocol
System.Boolean canListen
System.Boolean useDualMode
| Improve this Doc View Source

SIPTCPChannel(IPEndPoint, SIPProtocolsEnum, Encoding, Encoding, Boolean, Boolean)

Creates a SIP channel to listen for and send SIP messages over TCP.

Declaration
public SIPTCPChannel(IPEndPoint endPoint, SIPProtocolsEnum protocol, Encoding sipEncoding, Encoding sipBodyEncoding, bool canListen, bool useDualMode)
Parameters
Type Name Description
System.Net.IPEndPoint endPoint

The IP end point to send from and optionally listen on.

SIPProtocolsEnum protocol

Whether the channel is being used with TCP or TLS (TLS channels get upgraded once connected).

System.Text.Encoding sipEncoding
System.Text.Encoding sipBodyEncoding
System.Boolean canListen

Indicates whether the channel is capable of listening for new client connections. A TLS channel without a certificate cannot listen.

System.Boolean useDualMode
| Improve this Doc View Source

SIPTCPChannel(IPEndPoint, Boolean)

Declaration
public SIPTCPChannel(IPEndPoint endPoint, bool useDualMode = false)
Parameters
Type Name Description
System.Net.IPEndPoint endPoint
System.Boolean useDualMode
| Improve this Doc View Source

SIPTCPChannel(IPEndPoint, Encoding, Encoding, Boolean)

Declaration
public SIPTCPChannel(IPEndPoint endPoint, Encoding sipEncoding, Encoding sipBodyEncoding, bool useDualMode = false)
Parameters
Type Name Description
System.Net.IPEndPoint endPoint
System.Text.Encoding sipEncoding
System.Text.Encoding sipBodyEncoding
System.Boolean useDualMode

Fields

| Improve this Doc View Source

DisableLocalTCPSocketsCheck

Can be set to allow TCP channels hosted in the same process to send to each other. Useful for testing. By default sends between TCP channels in the same process are disabled to prevent resource exhaustion.

Declaration
public bool DisableLocalTCPSocketsCheck
Field Value
Type Description
System.Boolean
| Improve this Doc View Source

m_channelSocket

This is the main object managed by this class. It is the socket listening for incoming connections.

Declaration
protected Socket m_channelSocket
Field Value
Type Description
System.Net.Sockets.Socket
| Improve this Doc View Source

m_connectingSockets

List of sockets that are in the process of being connected to. Needed to avoid SIP re-transmits initiating multiple connect attempts.

Declaration
protected List<string> m_connectingSockets
Field Value
Type Description
System.Collections.Generic.List<System.String>

Properties

| Improve this Doc View Source

ProtDescr

This string is used in debug messages. It makes it possible to differentiate whether an instance in acting solely as a TCP channel or as the base class of a TLS channel.

Declaration
protected virtual string ProtDescr { get; }
Property Value
Type Description
System.String

Methods

| Improve this Doc View Source

Close()

Closes the channel and any open sockets.

Declaration
public override void Close()
Overrides
SIPChannel.Close()
| Improve this Doc View Source

Dispose()

Declaration
public override void Dispose()
Overrides
SIPChannel.Dispose()
| Improve this Doc View Source

HasConnection(SIPEndPoint)

Checks whether there is an existing connection for a remote end point. Existing connections include connections that have been accepted by this channel's listener and connections that have been initiated due to sends from this channel.

Declaration
public override bool HasConnection(SIPEndPoint remoteEndPoint)
Parameters
Type Name Description
SIPEndPoint remoteEndPoint

The remote end point to check for an existing connection.

Returns
Type Description
System.Boolean

True if there is a connection or false if not.

Overrides
SIPChannel.HasConnection(SIPEndPoint)
| Improve this Doc View Source

HasConnection(String)

Checks whether the SIP channel has a connection matching a unique connection ID.

Declaration
public override bool HasConnection(string connectionID)
Parameters
Type Name Description
System.String connectionID

The connection ID to check for a match on.

Returns
Type Description
System.Boolean

True if a match is found or false if not.

Overrides
SIPChannel.HasConnection(String)
| Improve this Doc View Source

HasConnection(Uri)

Not implemented for the TCP channel.

Declaration
public override bool HasConnection(Uri serverUri)
Parameters
Type Name Description
System.Uri serverUri
Returns
Type Description
System.Boolean
Overrides
SIPChannel.HasConnection(Uri)
| Improve this Doc View Source

IsAddressFamilySupported(AddressFamily)

Checks whether the specified address family is supported.

Declaration
public override bool IsAddressFamilySupported(AddressFamily addresFamily)
Parameters
Type Name Description
System.Net.Sockets.AddressFamily addresFamily

The address family to check.

Returns
Type Description
System.Boolean

True if supported, false if not.

Overrides
SIPChannel.IsAddressFamilySupported(AddressFamily)
| Improve this Doc View Source

IsProtocolSupported(SIPProtocolsEnum)

Checks whether the specified protocol is supported.

Declaration
public override bool IsProtocolSupported(SIPProtocolsEnum protocol)
Parameters
Type Name Description
SIPProtocolsEnum protocol

The protocol to check.

Returns
Type Description
System.Boolean

True if supported, false if not.

Overrides
SIPChannel.IsProtocolSupported(SIPProtocolsEnum)
| Improve this Doc View Source

OnAccept(SIPStreamConnection)

For TCP channel no special action is required when accepting a new client connection. Can start receiving immediately.

Declaration
protected virtual void OnAccept(SIPStreamConnection streamConnection)
Parameters
Type Name Description
SIPStreamConnection streamConnection

The stream connection holding the newly accepted client socket.

| Improve this Doc View Source

OnClientConnect(SIPStreamConnection, String)

For TCP channel no special action is required when a new outgoing client connection is established. Can start receiving immediately.

Declaration
protected virtual Task<SocketError> OnClientConnect(SIPStreamConnection streamConnection, string certificateName)
Parameters
Type Name Description
SIPStreamConnection streamConnection

The stream connection holding the newly connected client socket.

System.String certificateName
Returns
Type Description
System.Threading.Tasks.Task<System.Net.Sockets.SocketError>
| Improve this Doc View Source

OnSIPStreamDisconnected(SIPStreamConnection, SocketError)

Event handler for a reliable SIP stream socket being disconnected.

Declaration
protected void OnSIPStreamDisconnected(SIPStreamConnection connection, SocketError socketError)
Parameters
Type Name Description
SIPStreamConnection connection

The disconnected stream.

System.Net.Sockets.SocketError socketError

The cause of the disconnect.

| Improve this Doc View Source

SendAsync(SIPEndPoint, Byte[], Boolean, String)

Declaration
public override Task<SocketError> SendAsync(SIPEndPoint dstEndPoint, byte[] buffer, bool canInitiateConnection, string connectionIDHint)
Parameters
Type Name Description
SIPEndPoint dstEndPoint
System.Byte[] buffer
System.Boolean canInitiateConnection
System.String connectionIDHint
Returns
Type Description
System.Threading.Tasks.Task<System.Net.Sockets.SocketError>
Overrides
SIPChannel.SendAsync(SIPEndPoint, Byte[], Boolean, String)
| Improve this Doc View Source

SendOnConnected(SIPStreamConnection, Byte[])

Sends data once the stream is connected. Can be overridden in sub classes that need to implement a different mechanism to send. For example SSL connections.

Declaration
protected virtual Task SendOnConnected(SIPStreamConnection sipStreamConn, byte[] buffer)
Parameters
Type Name Description
SIPStreamConnection sipStreamConn

The connected SIP stream wrapping the TCP connection.

System.Byte[] buffer

The data to send.

Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

SendSecureAsync(SIPEndPoint, Byte[], String, Boolean, String)

Attempts to send data to the remote end point over a reliable connection. If an existing connection exists it will be used otherwise an attempt will be made to establish a new connection.

Declaration
public override Task<SocketError> SendSecureAsync(SIPEndPoint dstSIPEndPoint, byte[] buffer, string serverCertificateName, bool canInitiateConnection, string connectionIDHint)
Parameters
Type Name Description
SIPEndPoint dstSIPEndPoint

The remote SIP end point to send the reliable data to.

System.Byte[] buffer

The data to send.

System.String serverCertificateName

Optional. Only relevant for SSL streams. The common name that is expected for the remote SSL server.

System.Boolean canInitiateConnection

Indicates whether this send should initiate a connection if needed. The typical case is SIP requests can initiate new connections but responses should not. Responses should only be sent on the same TCP or TLS connection that the original request was received on.

System.String connectionIDHint

Optional. The ID of the specific TCP connection to try and the send the message on.

Returns
Type Description
System.Threading.Tasks.Task<System.Net.Sockets.SocketError>

If no errors SocketError.Success otherwise an error value.

Overrides
SIPChannel.SendSecureAsync(SIPEndPoint, Byte[], String, Boolean, String)
| Improve this Doc View Source

SIPTCPMessageReceived(SIPChannel, SIPEndPoint, SIPEndPoint, Byte[])

Gets fired when a suspected SIP message is extracted from the TCP data stream.

Declaration
protected Task SIPTCPMessageReceived(SIPChannel channel, SIPEndPoint localEndPoint, SIPEndPoint remoteEndPoint, byte[] buffer)
Parameters
Type Name Description
SIPChannel channel
SIPEndPoint localEndPoint
SIPEndPoint remoteEndPoint
System.Byte[] buffer
Returns
Type Description
System.Threading.Tasks.Task

Implements

System.IDisposable

Extension Methods

JSONWriter.ToJson(Object)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX