fm.liveswitch.StreamSocket Class Referenceabstract

A stream socket. More...

Public Member Functions

abstract void acceptAsync (fm.liveswitch.IAction0 onSuccess, fm.liveswitch.IAction1< java.lang.Exception > onFailure, fm.liveswitch.IAction1< fm.liveswitch.StreamSocket > onSocket)
 Accepts a new socket asynchronously. More...
 
abstract void connectAsync (String hostname, String ipAddress, int port, int timeout, fm.liveswitch.IAction0 onSuccess, fm.liveswitch.IAction2< java.lang.Exception, Boolean > onFailure)
 Connects the socket asynchronously. More...
 
fm.liveswitch.IAction2< java.lang.Exception, Boolean > getOnReceiveFailure ()
 Gets a callback invoked on failed read from TCP stream. More...
 
fm.liveswitch.IAction1< fm.liveswitch.DataBuffergetOnReceiveSuccess ()
 Gets a callback invoked on successful read from TCP stream. More...
 
abstract String getRemoteHostname ()
 Gets the remote hostname. More...
 
abstract String getRemoteIPAddress ()
 Gets the remote IP address. More...
 
abstract int getRemotePort ()
 Gets the remote port. More...
 
abstract boolean getSecure ()
 Gets a value indicating whether the socket is secure. More...
 
abstract boolean getServer ()
 Gets a value indicating whether the socket can accept incoming connections. More...
 
abstract void receiveAsync (int timeout)
 Receives data asynchronously. More...
 
abstract boolean send (fm.liveswitch.DataBuffer buffer)
 Sends data synchronously. More...
 
abstract void sendAsync (fm.liveswitch.DataBuffer buffer, int timeout, fm.liveswitch.IAction0 onSuccess, fm.liveswitch.IAction2< java.lang.Exception, Boolean > onFailure)
 Sends data asynchronously. More...
 
void setOnReceiveFailure (fm.liveswitch.IAction2< java.lang.Exception, Boolean > value)
 Sets a callback invoked on failed read from TCP stream. More...
 
void setOnReceiveSuccess (fm.liveswitch.IAction1< fm.liveswitch.DataBuffer > value)
 Sets a callback invoked on successful read from TCP stream. More...
 
- Public Member Functions inherited from fm.liveswitch.ManagedSocket
abstract boolean bind (String ipAddress, int port, fm.liveswitch.BooleanHolder addressInUse)
 Binds the socket to a local endpoint. More...
 
abstract void close ()
 Closes the socket. More...
 
long getAdapterSpeed ()
 Gets the adapter speed. More...
 
abstract boolean getIPv6 ()
 Gets a value indicating whether the socket supports IPv6. More...
 
abstract boolean getIsClosed ()
 Gets a value indicating whether this instance is closed. More...
 
abstract String getLocalIPAddress ()
 Gets the local IP address. More...
 
abstract int getLocalPort ()
 Gets the local port. More...
 
String[] getPublicIPAddresses ()
 Gets the public IP addresses, if known. More...
 
void setAdapterSpeed (long value)
 Sets the adapter speed. More...
 
void setPublicIPAddresses (String[] value)
 Sets the public IP addresses, if known. More...
 

Protected Member Functions

void raiseAcceptFailure (fm.liveswitch.IAction1< java.lang.Exception > callback, java.lang.Exception exception)
 Invokes the accept failure callback. More...
 
void raiseAcceptSocket (fm.liveswitch.IAction1< fm.liveswitch.StreamSocket > callback, fm.liveswitch.StreamSocket socket)
 Invokes the accept success callback. More...
 
void raiseAcceptSuccess (fm.liveswitch.IAction0 callback)
 Invokes the accept success callback. More...
 
void raiseConnectFailure (fm.liveswitch.IAction2< java.lang.Exception, Boolean > callback, java.lang.Exception exception, boolean timedOut)
 Invokes the connect failure callback. More...
 
void raiseConnectSuccess (fm.liveswitch.IAction0 callback)
 Invokes the connect success callback. More...
 
void raiseReceiveFailure (fm.liveswitch.IAction2< java.lang.Exception, Boolean > callback, java.lang.Exception exception, boolean timedOut)
 Invokes the receive failure callback. More...
 
void raiseReceiveSuccess (fm.liveswitch.IAction1< fm.liveswitch.DataBuffer > callback, fm.liveswitch.DataBuffer buffer)
 Invokes the receive success callback. More...
 
void raiseSendFailure (fm.liveswitch.IAction2< java.lang.Exception, Boolean > callback, java.lang.Exception exception, boolean timedOut)
 Invokes the send failure callback. More...
 
void raiseSendSuccess (fm.liveswitch.IAction0 callback)
 Invokes the send success callback. More...
 
 StreamSocket ()
 
- Protected Member Functions inherited from fm.liveswitch.ManagedSocket
 ManagedSocket ()
 

Detailed Description

A stream socket.

Constructor & Destructor Documentation

◆ StreamSocket()

fm.liveswitch.StreamSocket.StreamSocket ( )
protected

Member Function Documentation

◆ acceptAsync()

abstract void fm.liveswitch.StreamSocket.acceptAsync ( fm.liveswitch.IAction0  onSuccess,
fm.liveswitch.IAction1< java.lang.Exception >  onFailure,
fm.liveswitch.IAction1< fm.liveswitch.StreamSocket onSocket 
)
abstract

Accepts a new socket asynchronously.

Parameters
onSuccessThe callback to invoke on success.
onFailureThe callback to invoke on failure.
onSocketThe callback to invoke when a socket is ready.

◆ connectAsync()

abstract void fm.liveswitch.StreamSocket.connectAsync ( String  hostname,
String  ipAddress,
int  port,
int  timeout,
fm.liveswitch.IAction0  onSuccess,
fm.liveswitch.IAction2< java.lang.Exception, Boolean >  onFailure 
)
abstract

Connects the socket asynchronously.

Parameters
hostnameThe remote hostname.
ipAddressThe remote IP address.
portThe remote port.
timeoutThe timeout (in ms).
onSuccessThe callback to invoke on success.
onFailureThe callback to invoke on failure.

◆ getOnReceiveFailure()

fm.liveswitch.IAction2<java.lang.Exception,Boolean> fm.liveswitch.StreamSocket.getOnReceiveFailure ( )

Gets a callback invoked on failed read from TCP stream.

◆ getOnReceiveSuccess()

fm.liveswitch.IAction1<fm.liveswitch.DataBuffer> fm.liveswitch.StreamSocket.getOnReceiveSuccess ( )

Gets a callback invoked on successful read from TCP stream.

◆ getRemoteHostname()

abstract String fm.liveswitch.StreamSocket.getRemoteHostname ( )
abstract

Gets the remote hostname.

Reimplemented in fm.liveswitch.TcpSocket.

◆ getRemoteIPAddress()

abstract String fm.liveswitch.StreamSocket.getRemoteIPAddress ( )
abstract

Gets the remote IP address.

Reimplemented in fm.liveswitch.TcpSocket.

◆ getRemotePort()

abstract int fm.liveswitch.StreamSocket.getRemotePort ( )
abstract

Gets the remote port.

Reimplemented in fm.liveswitch.TcpSocket.

◆ getSecure()

abstract boolean fm.liveswitch.StreamSocket.getSecure ( )
abstract

Gets a value indicating whether the socket is secure.

Reimplemented in fm.liveswitch.TcpSocket.

◆ getServer()

abstract boolean fm.liveswitch.StreamSocket.getServer ( )
abstract

Gets a value indicating whether the socket can accept incoming connections.

Reimplemented in fm.liveswitch.TcpSocket.

◆ raiseAcceptFailure()

void fm.liveswitch.StreamSocket.raiseAcceptFailure ( fm.liveswitch.IAction1< java.lang.Exception >  callback,
java.lang.Exception  exception 
)
protected

Invokes the accept failure callback.

Parameters
callbackThe callback.
exceptionThe exception.

◆ raiseAcceptSocket()

void fm.liveswitch.StreamSocket.raiseAcceptSocket ( fm.liveswitch.IAction1< fm.liveswitch.StreamSocket callback,
fm.liveswitch.StreamSocket  socket 
)
protected

Invokes the accept success callback.

Parameters
callbackThe callback.
socketThe socket.

◆ raiseAcceptSuccess()

void fm.liveswitch.StreamSocket.raiseAcceptSuccess ( fm.liveswitch.IAction0  callback)
protected

Invokes the accept success callback.

Parameters
callbackThe callback.

◆ raiseConnectFailure()

void fm.liveswitch.StreamSocket.raiseConnectFailure ( fm.liveswitch.IAction2< java.lang.Exception, Boolean >  callback,
java.lang.Exception  exception,
boolean  timedOut 
)
protected

Invokes the connect failure callback.

Parameters
callbackThe callback.
exceptionThe exception.
timedOutif set to
true
[timed out].

◆ raiseConnectSuccess()

void fm.liveswitch.StreamSocket.raiseConnectSuccess ( fm.liveswitch.IAction0  callback)
protected

Invokes the connect success callback.

Parameters
callbackThe callback.

◆ raiseReceiveFailure()

void fm.liveswitch.StreamSocket.raiseReceiveFailure ( fm.liveswitch.IAction2< java.lang.Exception, Boolean >  callback,
java.lang.Exception  exception,
boolean  timedOut 
)
protected

Invokes the receive failure callback.

Parameters
callbackThe callback.
exceptionThe exception.
timedOutif set to
true
[timed out].

◆ raiseReceiveSuccess()

void fm.liveswitch.StreamSocket.raiseReceiveSuccess ( fm.liveswitch.IAction1< fm.liveswitch.DataBuffer callback,
fm.liveswitch.DataBuffer  buffer 
)
protected

Invokes the receive success callback.

Parameters
callbackThe callback.
bufferThe buffer.

◆ raiseSendFailure()

void fm.liveswitch.StreamSocket.raiseSendFailure ( fm.liveswitch.IAction2< java.lang.Exception, Boolean >  callback,
java.lang.Exception  exception,
boolean  timedOut 
)
protected

Invokes the send failure callback.

Parameters
callbackThe callback.
exceptionThe exception.
timedOutif set to
true
[timed out].

◆ raiseSendSuccess()

void fm.liveswitch.StreamSocket.raiseSendSuccess ( fm.liveswitch.IAction0  callback)
protected

Invokes the send success callback.

Parameters
callbackThe callback.

◆ receiveAsync()

abstract void fm.liveswitch.StreamSocket.receiveAsync ( int  timeout)
abstract

Receives data asynchronously.

Parameters
timeoutThe timeout (in ms).

Reimplemented in fm.liveswitch.TcpSocket.

◆ send()

abstract boolean fm.liveswitch.StreamSocket.send ( fm.liveswitch.DataBuffer  buffer)
abstract

Sends data synchronously.

Parameters
bufferThe buffer.

◆ sendAsync()

abstract void fm.liveswitch.StreamSocket.sendAsync ( fm.liveswitch.DataBuffer  buffer,
int  timeout,
fm.liveswitch.IAction0  onSuccess,
fm.liveswitch.IAction2< java.lang.Exception, Boolean >  onFailure 
)
abstract

Sends data asynchronously.

Parameters
bufferThe buffer.
timeoutThe timeout (in ms).
onSuccessThe callback to invoke on success.
onFailureThe callback to invoke on failure.

◆ setOnReceiveFailure()

void fm.liveswitch.StreamSocket.setOnReceiveFailure ( fm.liveswitch.IAction2< java.lang.Exception, Boolean >  value)

Sets a callback invoked on failed read from TCP stream.

◆ setOnReceiveSuccess()

void fm.liveswitch.StreamSocket.setOnReceiveSuccess ( fm.liveswitch.IAction1< fm.liveswitch.DataBuffer value)

Sets a callback invoked on successful read from TCP stream.