Show / Hide Table of Contents

Class ErlAbstractConnection

Maintains a connection between a C# process and a remote Erlang, C# or C node. The object maintains connection state and allows data to be sent to and received from the peer

Inheritance
System.Object
DisposableObject
ErlAbstractConnection
ErlConnection
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.Erlang
Assembly: NFX.Erlang.dll
Syntax
public abstract class ErlAbstractConnection : DisposableObject, IDisposable
Remarks

This abstract class provides the neccesary methods to maintain the actual connection and encode the messages and headers in the proper format according to the Erlang distribution protocol. Subclasses can use these methods to provide a more or less transparent communication channel as desired.

Note that no receive methods are provided. Subclasses must provide methods for message delivery, and may implement their own receive methods.

If an exception occurs in any of the methods in this class, the connection will be closed and must be reopened in order to resume communication with the peer. This will be indicated to the subclass by passing the exception to its delivery() method

Constructors

ErlAbstractConnection(ErlLocalNode, ErlRemoteNode, Nullable<ErlAtom>, Boolean)

Intiate and open a connection to a remote node

Declaration
protected ErlAbstractConnection(ErlLocalNode self, ErlRemoteNode other, ErlAtom? cookie = default (ErlAtom? ), bool connect = true)
Parameters
Type Name Description
ErlLocalNode self
ErlRemoteNode other
System.Nullable<ErlAtom> cookie
System.Boolean connect

ErlAbstractConnection(ErlLocalNode, IErlTransport)

Accept an incoming connection from a remote node. Used by ErlLocalNode.Accept to create a connection based on data received when handshaking with the peer node, when the remote node is the connection intitiator.

Declaration
protected ErlAbstractConnection(ErlLocalNode home, IErlTransport s)
Parameters
Type Name Description
ErlLocalNode home
IErlTransport s

Fields

CHALLENGE_ACK

Declaration
protected const int CHALLENGE_ACK = 97
Field Value
Type Description
System.Int32

CHALLENGE_REPLY

Declaration
protected const int CHALLENGE_REPLY = 114
Field Value
Type Description
System.Int32

CHALLENGE_STATUS

Declaration
protected const int CHALLENGE_STATUS = 115
Field Value
Type Description
System.Int32

DEFAULT_MAX_PAYLOAD_LENGTH

Declaration
protected const int DEFAULT_MAX_PAYLOAD_LENGTH = 134217728
Field Value
Type Description
System.Int32

HEADER_LEN

Declaration
protected const int HEADER_LEN = 2048
Field Value
Type Description
System.Int32

m_Connected

Declaration
protected bool m_Connected
Field Value
Type Description
System.Boolean

m_Cookie

Declaration
protected ErlAtom m_Cookie
Field Value
Type Description
ErlAtom

m_CookieOk

Declaration
protected bool m_CookieOk
Field Value
Type Description
System.Boolean

m_Home

Declaration
protected ErlLocalNode m_Home
Field Value
Type Description
ErlLocalNode

m_Peer

Declaration
protected ErlRemoteNode m_Peer
Field Value
Type Description
ErlRemoteNode

m_ShouldSendCookie

Declaration
protected bool m_ShouldSendCookie
Field Value
Type Description
System.Boolean

m_Transport

Declaration
protected IErlTransport m_Transport
Field Value
Type Description
IErlTransport

PASS_THROUGH

Declaration
protected const byte PASS_THROUGH = 112
Field Value
Type Description
System.Byte

s_Random

Declaration
protected static Random s_Random
Field Value
Type Description
System.Random

Properties

Connected

Determine if the connection is still alive. Note that this method only reports the status of the connection, and that it is possible that there are unread messages waiting in the receive queue

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

ConnectTimeout

Declaration
public static int ConnectTimeout { get; set; }
Property Value
Type Description
System.Int32

Cookie

Declaration
public ErlAtom Cookie { get; }
Property Value
Type Description
ErlAtom

LocalNode

Declaration
public ErlLocalNode LocalNode { get; }
Property Value
Type Description
ErlLocalNode

MaxPayloadLength

Max size of the message accepted from the peer. The connection will be closed if a message is received of size greater than this.

Declaration
public int MaxPayloadLength { get; set; }
Property Value
Type Description
System.Int32

Name

Declaration
public ErlAtom Name { get; }
Property Value
Type Description
ErlAtom

ReceivedBytes

Total number of bytes received from connection

Declaration
public long ReceivedBytes { get; }
Property Value
Type Description
System.Int64

ReceivedMsgs

Total number of messages received from connection

Declaration
public long ReceivedMsgs { get; }
Property Value
Type Description
System.Int64

RemoteNode

Declaration
public ErlRemoteNode RemoteNode { get; }
Property Value
Type Description
ErlRemoteNode

SendCookie

Cookie to send along with each distribution message

Declaration
protected ErlAtom SendCookie { get; }
Property Value
Type Description
ErlAtom

SentBytes

Total number of bytes sent through connection

Declaration
public long SentBytes { get; }
Property Value
Type Description
System.Int64

SentMsgs

Total number of messages sent through connection

Declaration
public long SentMsgs { get; }
Property Value
Type Description
System.Int64

TraceLevel

Set the trace level for this connection. Normally tracing is off by default

Declaration
public ErlTraceLevel TraceLevel { get; }
Property Value
Type Description
ErlTraceLevel

Methods

Close()

Close the connection to the remote node

Declaration
protected virtual void Close()

Deliver(ErlConnectionException)

Deliver communication exceptions to the recipient

Declaration
protected abstract void Deliver(ErlConnectionException e)
Parameters
Type Name Description
ErlConnectionException e

Deliver(ErlMsg)

Deliver messages to the recipient

Declaration
protected abstract void Deliver(ErlMsg msg)
Parameters
Type Name Description
ErlMsg msg

Destructor()

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

DoSend(ErlOutputStream, ErlOutputStream)

Declaration
protected void DoSend(ErlOutputStream header, ErlOutputStream payload = null)
Parameters
Type Name Description
ErlOutputStream header
ErlOutputStream payload

HeaderType(IErlObject)

Declaration
protected string HeaderType(IErlObject h)
Parameters
Type Name Description
IErlObject h
Returns
Type Description
System.String

ReadSock(Byte[], Int32, Boolean)

Read data from socket

Declaration
protected int ReadSock(byte[] b, int sz, bool readingPayload)
Parameters
Type Name Description
System.Byte[] b
System.Int32 sz
System.Boolean readingPayload
Returns
Type Description
System.Int32
Remarks

This method now throws exception if we don't get full read

SendRPC(ErlPid, String, String, ErlList)

Send an RPC request to the remote Erlang node

Declaration
public void SendRPC(ErlPid from, string mod, string fun, ErlList args)
Parameters
Type Name Description
ErlPid from
System.String mod
System.String fun
ErlList args
Remarks

This convenience function creates the following message and sends it to 'rex' on the remote node:

{ Self, { call, Mod, Fun, Args, user }}

Note that this method has unpredicatble results if the remote node is not an Erlang node

SendRPCcast(ErlPid, String, String, ErlList)

Send an RPC cast request to the remote Erlang node

Declaration
public void SendRPCcast(ErlPid from, string mod, string fun, ErlList args)
Parameters
Type Name Description
ErlPid from
System.String mod
System.String fun
ErlList args

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