Stream

public class Stream

The class representing Carrier stream.

Fields

PROPERTY_COMPRESS

public static int PROPERTY_COMPRESS

PROPERTY_MULTIPLEXING

public static int PROPERTY_MULTIPLEXING

PROPERTY_PLAIN

public static int PROPERTY_PLAIN

PROPERTY_PORT_FORWARDING

public static int PROPERTY_PORT_FORWARDING

PROPERTY_RELIABLE

public static int PROPERTY_RELIABLE

Methods

closeChannel

public void closeChannel(int channel)

Close a new channel on multiplexing stream. If the stream is not multiplexing this function will throw exception.

Parameters
  • channel – The channel ID to close

Throws

closePortForwarding

public void closePortForwarding(int portForwarding)

Close a port forwarding. If the stream is not multiplexing this function will throw exception.

Parameters
  • portForwarding – The portforwarding ID.

Throws

getStreamId

public int getStreamId()

getTransportInfo

public TransportInfo getTransportInfo()

Get tranport info of carrier stream.

Returns

The transport info of this stream.

getType

public StreamType getType()

Get the carrier stream type.

Returns

The stream type defined in StreamType.

openChannel

public int openChannel(String cookie)

Open a new channel on multiplexing stream. If the stream is not multiplexing this function will throw exception.

Parameters
  • cookie – The application defined data passed to remote peer

Throws
Returns

New channel ID

openPortFowarding

public int openPortFowarding(String service, PortForwardingProtocol protocol, String host, String port)

Open a port forwarding to remote service over multiplexing. If the stream is not multiplexing this function will throw exception.

Parameters
  • service – The remote service name

  • protocol – Port forwarding protocol

  • host – Local host or ip to binding If host is null, port forwarding will bind to localhost

  • port – Local port to binding, can not be nil.

Throws
Returns

Port forwarding ID

pendChannel

public void pendChannel(int channel)

Request remote peer to pend channel data sending. If the stream is not multiplexing this function will throw exception.

Parameters
  • channel – The channel ID

Throws

resumeChannel

public void resumeChannel(int channel)

Request remote peer to resume channel data sending. If the stream is not multiplexing this function will throw exception.

Parameters
  • channel – The channel ID

Throws

writeData

public int writeData(byte[] data, int offset, int len)

Send outgoing data to remote peer. If the stream is in multiplexing mode, application can not call this function to send data. If this function is called on multiplexing mode stream, it will throw exception.

Parameters
  • data – The outgoing data offset The start offset len The bytes to write

Throws
Returns

Bytes of data sent on success

writeData

public int writeData(byte[] data)

Send outgoing data to remote peer. If the stream is in multiplexing mode, application can not call this function to send data. If this function is called on multiplexing mode stream, it will throw exception.

Parameters
  • data – The outgoing data

Throws
Returns

Bytes of data sent on success

writeData

public int writeData(byte data)

Send outgoing data to remote peer. If the stream is in multiplexing mode, application can not call this function to send data. If this function is called on multiplexing mode stream, it will throw exception.

Parameters
  • data – The outgoing data

Throws
Returns

Bytes of data sent on success

writeData

public int writeData(int channel, byte[] data, int offset, int len)

Send outgoing data to remote peer. If the stream is not multiplexing this function will throw exception.

Parameters
  • channel – [in] The channel ID

  • data – [in] The outgoing data offset [in] The start offset len [in] The bytes to write

Returns

Bytes of data sent on success.

writeData

public int writeData(int channel, byte[] data)

Send outgoing data to remote peer. If the stream is not multiplexing this function will throw exception.

Parameters
  • channel – [in] The channel ID

  • data – [in] The outgoing data

Returns

Bytes of data sent on success.

writeData

public int writeData(int channel, byte data)

Send outgoing data to remote peer. If the stream is not multiplexing this function will throw exception.

Parameters
  • channel – [in] The channel ID

  • data – [in] The outgoing data

Returns

Bytes of data sent on success.