Class StreamSocket
A stream socket.
Inherited Members
Namespace: FM.LiveSwitch
Assembly: FM.LiveSwitch.dll
Syntax
public abstract class StreamSocket : ManagedSocket
Properties
OnReceiveFailure
Gets or sets a callback invoked on failed read from TCP stream.
Declaration
public Action2<Exception, bool> OnReceiveFailure { get; set; }
Property Value
Type | Description |
---|---|
Action2<Exception, System.Boolean> |
OnReceiveSuccess
Gets or sets a callback invoked on successful read from TCP stream.
Declaration
public Action1<DataBuffer> OnReceiveSuccess { get; set; }
Property Value
Type | Description |
---|---|
Action1<DataBuffer> |
RemoteHostname
Gets or sets the remote hostname.
Declaration
public abstract string RemoteHostname { get; }
Property Value
Type | Description |
---|---|
System.String |
RemoteIPAddress
Gets or sets the remote IP address.
Declaration
public abstract string RemoteIPAddress { get; }
Property Value
Type | Description |
---|---|
System.String |
RemotePort
Gets or sets the remote port.
Declaration
public abstract int RemotePort { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Secure
Gets a value indicating whether the socket is secure.
Declaration
public abstract bool Secure { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Server
Gets a value indicating whether the socket can accept incoming connections.
Declaration
public abstract bool Server { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
AcceptAsync(Action0, Action1<Exception>, Action1<StreamSocket>)
Accepts a new socket asynchronously.
Declaration
public abstract void AcceptAsync(Action0 onSuccess, Action1<Exception> onFailure, Action1<StreamSocket> onSocket)
Parameters
Type | Name | Description |
---|---|---|
Action0 | onSuccess | The callback to invoke on success. |
Action1<Exception> | onFailure | The callback to invoke on failure. |
Action1<StreamSocket> | onSocket | The callback to invoke when a socket is ready. |
ConnectAsync(String, String, Int32, Int32, Action0, Action2<Exception, Boolean>)
Connects the socket asynchronously.
Declaration
public abstract void ConnectAsync(string hostname, string ipAddress, int port, int timeout, Action0 onSuccess, Action2<Exception, bool> onFailure)
Parameters
Type | Name | Description |
---|---|---|
System.String | hostname | The remote hostname. |
System.String | ipAddress | The remote IP address. |
System.Int32 | port | The remote port. |
System.Int32 | timeout | The timeout (in ms). |
Action0 | onSuccess | The callback to invoke on success. |
Action2<Exception, System.Boolean> | onFailure | The callback to invoke on failure. |
RaiseAcceptFailure(Action1<Exception>, Exception)
Invokes the accept failure callback.
Declaration
protected void RaiseAcceptFailure(Action1<Exception> callback, Exception exception)
Parameters
Type | Name | Description |
---|---|---|
Action1<Exception> | callback | The callback. |
Exception | exception | The exception. |
RaiseAcceptSocket(Action1<StreamSocket>, StreamSocket)
Invokes the accept success callback.
Declaration
protected void RaiseAcceptSocket(Action1<StreamSocket> callback, StreamSocket socket)
Parameters
Type | Name | Description |
---|---|---|
Action1<StreamSocket> | callback | The callback. |
StreamSocket | socket | The socket. |
RaiseAcceptSuccess(Action0)
Invokes the accept success callback.
Declaration
protected void RaiseAcceptSuccess(Action0 callback)
Parameters
Type | Name | Description |
---|---|---|
Action0 | callback | The callback. |
RaiseConnectFailure(Action2<Exception, Boolean>, Exception, Boolean)
Invokes the connect failure callback.
Declaration
protected void RaiseConnectFailure(Action2<Exception, bool> callback, Exception exception, bool timedOut)
Parameters
Type | Name | Description |
---|---|---|
Action2<Exception, System.Boolean> | callback | The callback. |
Exception | exception | The exception. |
System.Boolean | timedOut | if set to |
RaiseConnectSuccess(Action0)
Invokes the connect success callback.
Declaration
protected void RaiseConnectSuccess(Action0 callback)
Parameters
Type | Name | Description |
---|---|---|
Action0 | callback | The callback. |
RaiseReceiveFailure(Action2<Exception, Boolean>, Exception, Boolean)
Invokes the receive failure callback.
Declaration
protected void RaiseReceiveFailure(Action2<Exception, bool> callback, Exception exception, bool timedOut)
Parameters
Type | Name | Description |
---|---|---|
Action2<Exception, System.Boolean> | callback | The callback. |
Exception | exception | The exception. |
System.Boolean | timedOut | if set to |
RaiseReceiveSuccess(Action1<DataBuffer>, DataBuffer)
Invokes the receive success callback.
Declaration
protected void RaiseReceiveSuccess(Action1<DataBuffer> callback, DataBuffer buffer)
Parameters
Type | Name | Description |
---|---|---|
Action1<DataBuffer> | callback | The callback. |
DataBuffer | buffer | The buffer. |
RaiseSendFailure(Action2<Exception, Boolean>, Exception, Boolean)
Invokes the send failure callback.
Declaration
protected void RaiseSendFailure(Action2<Exception, bool> callback, Exception exception, bool timedOut)
Parameters
Type | Name | Description |
---|---|---|
Action2<Exception, System.Boolean> | callback | The callback. |
Exception | exception | The exception. |
System.Boolean | timedOut | if set to |
RaiseSendSuccess(Action0)
Invokes the send success callback.
Declaration
protected void RaiseSendSuccess(Action0 callback)
Parameters
Type | Name | Description |
---|---|---|
Action0 | callback | The callback. |
ReceiveAsync(Int32)
Receives data asynchronously.
Declaration
public abstract void ReceiveAsync(int timeout)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | timeout | The timeout (in ms). |
Send(DataBuffer)
Sends data synchronously.
Declaration
public abstract bool Send(DataBuffer buffer)
Parameters
Type | Name | Description |
---|---|---|
DataBuffer | buffer | The buffer. |
Returns
Type | Description |
---|---|
System.Boolean |
SendAsync(DataBuffer, Int32, Action0, Action2<Exception, Boolean>)
Sends data asynchronously.
Declaration
public abstract void SendAsync(DataBuffer buffer, int timeout, Action0 onSuccess, Action2<Exception, bool> onFailure)
Parameters
Type | Name | Description |
---|---|---|
DataBuffer | buffer | The buffer. |
System.Int32 | timeout | The timeout (in ms). |
Action0 | onSuccess | The callback to invoke on success. |
Action2<Exception, System.Boolean> | onFailure | The callback to invoke on failure. |