Show / Hide Table of Contents

Class MpxSocket<TTransport>

Base for MpxSockets implementation. An MpxSocket represents an asynchronous bi-directional channel of communication that delivers binary/wire messages of flexible size. The socket is NOT THREAD SAFE for calling Send() from parallel threads. Send() is done synchronously on the calling thread, i.e. the sender waits until the data is written into the OS socket buff. Receive is invoked by internal/system/io thread asynchronously and should not block for long (seconds)

Inheritance
System.Object
DisposableObject
MpxSocket<TTransport>
MpxClientSocket
MpxServerSocket
Implements
System.IDisposable
Inherited Members
DisposableObject.DisposeAndNull<T>(T)
DisposableObject.DisposeStarted
DisposableObject.Disposed
DisposableObject.EnsureObjectNotDisposed()
DisposableObject.Dispose()
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: NFX.Glue.Native
Assembly: NFX.dll
Syntax
public abstract class MpxSocket<TTransport> : DisposableObject, IDisposable where TTransport : Transport, IMpxTransport
Type Parameters
Name Description
TTransport

Constructors

MpxSocket(TTransport, IPEndPoint, ClientSite, MpxSocketReceiveAction<TTransport>)

Declaration
protected MpxSocket(TTransport transport, IPEndPoint endPoint, ClientSite clientSite, MpxSocketReceiveAction<TTransport> receiveAction)
Parameters
Type Name Description
TTransport transport
System.Net.IPEndPoint endPoint
ClientSite clientSite
MpxSocketReceiveAction<TTransport> receiveAction

Fields

m_ClientSite

Declaration
protected readonly ClientSite m_ClientSite
Field Value
Type Description
ClientSite

m_Disposing

Declaration
protected volatile bool m_Disposing
Field Value
Type Description
System.Boolean

m_EndPoint

Declaration
protected readonly IPEndPoint m_EndPoint
Field Value
Type Description
System.Net.IPEndPoint

m_LastIdleManagerVisit

Declaration
protected DateTime? m_LastIdleManagerVisit
Field Value
Type Description
System.Nullable<System.DateTime>

m_ReceiveChunk

Declaration
protected MemChunk m_ReceiveChunk
Field Value
Type Description
MemChunk

m_SendChunk

Declaration
protected MemChunk m_SendChunk
Field Value
Type Description
MemChunk

m_Socket

Declaration
protected Socket m_Socket
Field Value
Type Description
System.Net.Sockets.Socket

m_Transport

Declaration
protected readonly TTransport m_Transport
Field Value
Type Description
TTransport

Properties

Active

True when socket is not disposing and runtime is not shutting down

Declaration
public bool Active { get; }
Property Value
Type Description
System.Boolean

ClientSite

Returns client site for the computer that initiated the call. Server socket returns the transmitted value from client. Client socket returns the one that was sent to server upon handshake

Declaration
public ClientSite ClientSite { get; }
Property Value
Type Description
ClientSite

EndPoint

Returns IP End point that this socket services, remote server for client socket and remote client for server sockets

Declaration
public IPEndPoint EndPoint { get; }
Property Value
Type Description
System.Net.IPEndPoint

LastIdleManagerVisit

Returns timestamp of last manager visit since then no traffic came through. Null indicates that traffic came though and socket has not been idle since last visit. Manager is an extrenal visitor that closes idle sockets

Declaration
public DateTime? LastIdleManagerVisit { get; }
Property Value
Type Description
System.Nullable<System.DateTime>

Socket

Returns the underlying socket

Declaration
public Socket Socket { get; }
Property Value
Type Description
System.Net.Sockets.Socket

Transport

Returns transport that this socket is under

Declaration
public TTransport Transport { get; }
Property Value
Type Description
TTransport

Methods

AcceptManagerVisit(DateTime)

Override to perform maintenance i.e. trim excessive m_SendChunk size etc.. This method is called by Glue/Binding/Transport runtime. Also resets last last idle manager visit timestamp which is used for socket closing

Declaration
public virtual void AcceptManagerVisit(DateTime when)
Parameters
Type Name Description
System.DateTime when

Destructor()

Declaration
protected override void Destructor()
Overrides
DisposableObject.Destructor()

DoReleaseMemChunksAfterAsyncOperations()

Do not call this method, override only when freeing more than 2 standard chunks (send/recv)

Declaration
protected virtual void DoReleaseMemChunksAfterAsyncOperations()

DoSend(WireMsg)

Declaration
protected abstract void DoSend(WireMsg data)
Parameters
Type Name Description
WireMsg data

GetSendChunk(Int32)

Reserves a chunk of memory of the suggested size for network send operation. The buffer must be released by a call to ReleaseSendBuffer(). Keep in mind that this method is NOT RE-ENTRANT by this or any other thread until corresponding ReleaseSendChunk() is called. MpxSocket is not thread safe for sends in general.

Declaration
public virtual MemChunk GetSendChunk(int desiredSize = 0)
Parameters
Type Name Description
System.Int32 desiredSize
Returns
Type Description
MemChunk

InvokeReceive(WireMsg)

Calls ReceiveAction callback guarding for possible unhandled receive action errors

Declaration
protected void InvokeReceive(WireMsg msg)
Parameters
Type Name Description
WireMsg msg

ReleaseMemChunksAfterAsyncOperations()

Releases socket memory chunks. This method MUST BE called AFTER all pending async IO is done, otherwise the chunks may get released to the pool and get corrupted by the prior operation

Declaration
protected void ReleaseMemChunksAfterAsyncOperations()

ReleaseSendChunk()

Releases previously reserved buffer, i.e. may trim excess allocation after a large message

Declaration
public virtual void ReleaseSendChunk()

Send(WireMsg)

Adds the specified socket msg to the outgoing stack. This is a synchronous blocking call that executes until the data is written into socket stack (but not necessarily delivered). If send error occurs then socket is marked as !Active (Disposed)

Declaration
public void Send(WireMsg data)
Parameters
Type Name Description
WireMsg data

Implements

System.IDisposable

Extension Methods

MiscUtils.NonNull<T>(T, Func<Exception>, String)
ObjectValueConversion.AsString(Object, String, ConvertErrorHandling)
ObjectValueConversion.AsNonNullOrEmptyString(Object)
ObjectValueConversion.AsLaconicConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsJSONConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsXMLConfig(Object, ConfigSectionNode, ConvertErrorHandling)
ObjectValueConversion.AsChar(Object, Char, ConvertErrorHandling)
ObjectValueConversion.AsNullableChar(Object, Nullable<Char>, ConvertErrorHandling)
ObjectValueConversion.AsByte(Object, Byte, ConvertErrorHandling)
ObjectValueConversion.AsNullableByte(Object, Nullable<Byte>, ConvertErrorHandling)
ObjectValueConversion.AsSByte(Object, SByte, ConvertErrorHandling)
ObjectValueConversion.AsNullableSByte(Object, Nullable<SByte>, ConvertErrorHandling)
ObjectValueConversion.AsShort(Object, Int16, ConvertErrorHandling)
ObjectValueConversion.AsNullableShort(Object, Nullable<Int16>, ConvertErrorHandling)
ObjectValueConversion.AsUShort(Object, UInt16, ConvertErrorHandling)
ObjectValueConversion.AsNullableUShort(Object, Nullable<UInt16>, ConvertErrorHandling)
ObjectValueConversion.AsInt(Object, Int32, ConvertErrorHandling)
ObjectValueConversion.AsNullableInt(Object, Nullable<Int32>, ConvertErrorHandling)
ObjectValueConversion.AsUInt(Object, UInt32, ConvertErrorHandling)
ObjectValueConversion.AsNullableUInt(Object, Nullable<UInt32>, ConvertErrorHandling)
ObjectValueConversion.AsLong(Object, Int64, ConvertErrorHandling)
ObjectValueConversion.AsNullableLong(Object, Nullable<Int64>, ConvertErrorHandling)
ObjectValueConversion.AsULong(Object, UInt64, ConvertErrorHandling)
ObjectValueConversion.AsNullableULong(Object, Nullable<UInt64>, ConvertErrorHandling)
ObjectValueConversion.AsDouble(Object, Double, ConvertErrorHandling)
ObjectValueConversion.AsNullableDouble(Object, Nullable<Double>, ConvertErrorHandling)
ObjectValueConversion.AsFloat(Object, Single, ConvertErrorHandling)
ObjectValueConversion.AsNullableFloat(Object, Nullable<Single>, ConvertErrorHandling)
ObjectValueConversion.AsDecimal(Object, Decimal, ConvertErrorHandling)
ObjectValueConversion.AsNullableDecimal(Object, Nullable<Decimal>, ConvertErrorHandling)
ObjectValueConversion.AsBool(Object, Boolean, ConvertErrorHandling)
ObjectValueConversion.AsNullableBool(Object, Nullable<Boolean>, ConvertErrorHandling)
ObjectValueConversion.AsGUID(Object, Guid, ConvertErrorHandling)
ObjectValueConversion.AsNullableGUID(Object, Nullable<Guid>, ConvertErrorHandling)
ObjectValueConversion.AsDateTime(Object)
ObjectValueConversion.AsDateTime(Object, DateTime, ConvertErrorHandling)
ObjectValueConversion.AsNullableDateTime(Object, Nullable<DateTime>, ConvertErrorHandling)
ObjectValueConversion.AsGDID(Object)
ObjectValueConversion.AsGDID(Object, GDID, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDID(Object, Nullable<GDID>, ConvertErrorHandling)
ObjectValueConversion.AsGDIDSymbol(Object)
ObjectValueConversion.AsGDIDSymbol(Object, GDIDSymbol, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDIDSymbol(Object, Nullable<GDIDSymbol>, ConvertErrorHandling)
ObjectValueConversion.AsTimeSpan(Object)
ObjectValueConversion.AsTimeSpan(Object, TimeSpan, ConvertErrorHandling)
ObjectValueConversion.AsNullableTimeSpan(Object, Nullable<TimeSpan>, ConvertErrorHandling)
ObjectValueConversion.AsEnum<TEnum>(Object, TEnum, ConvertErrorHandling)
ObjectValueConversion.AsNullableEnum<TEnum>(Object, Nullable<TEnum>, ConvertErrorHandling)
ObjectValueConversion.AsUri(Object, Uri, ConvertErrorHandling)
JSONExtensions.ToJSON(Object, JSONWritingOptions)
JSONExtensions.ToJSON(Object, TextWriter, JSONWritingOptions)
JSONExtensions.ToJSON(Object, Stream, JSONWritingOptions, Encoding)
ErlObject.ToErlObject(Object)
ErlObject.ToErlObject(Object, ErlTypeOrder, Boolean)
Back to top Copyright © 2006-2018 Agnicore Inc
Generated by DocFX