Poco::Remoting::Binary

class Transport

Library: Remoting/Binary
Package: Binary
Header: Poco/Remoting/Binary/Transport.h

Description

The Binary Transport implementation.

The Binary Transport uses a TCP (or SSL/TLS) socket connection with a proprietary binary protocol, based on Poco::BinaryWriter and Poco::BinaryReader. For more information about the protocol, please see the Serializer and Deserializer classes.

The following requirements must be met, so that one can use Binary as transport: On the server side one must:

  1. register the TransportFactory,
  2. register a Listener, and finally,
  3. register the individual objects.

Note that the performance of a binary transport is best when no namespaces are used and when the type of all parameters are scalar. While a binary transport will ignore namespaces and element/attr distinction, it will still be informed by de-/serializers which costs time. Also the generated code will be more compact.

Example:

Poco::Remoting::Binary::TransportFactory::registerFactory();
Poco::Remoting::ORB::instance().registerListener(
    new PocoRemoting::Binary::Listener(10001)
);
MyProject::MyClassHelper::registerObject(
    new MyProject::MyClass, 
    "MyObject", 
    10001, 
    Poco::Remoting::Binary::Transport::ID
);

On the client side, requirements are similar:

  1. register the TransportFactory, and
  2. retrieve the object using the helper class.

Example:

Poco::Remoting::Binary::TransportFactory::registerFactory();
MyProject::IMyClass::Ptr ptrObj = MyProject::MyClassHelper::findObject(
    hostName, 
    "MyObject", 
    10001, 
    Poco::Remoting::Binary::Transport::ID
);

Inheritance

Direct Base Classes: Poco::Remoting::Transport

All Base Classes: Poco::Remoting::Transport

Member Summary

Member Functions: connect, connected, disconnect, doExecute, doExecuteOneWay, endExecute, endPoint, getDeserializer, getSerializer, prepareExecute, prepareExecuteOneWay

Inherited Functions: connect, connected, disconnect, doExecute, doExecuteOneWay, endExecute, endPoint, getDeserializer, getSerializer, prepareExecute, prepareExecuteOneWay

Nested Classes

class SocketFactory

SocketFactory is used by the Transport to create a socket for the connection to the listener on the server. more...

Constructors

Transport

Transport(
    bool lateConnect,
    bool reconnect,
    SocketFactory::Ptr pSocketFactory = 0
);

Creates the Transport with an uninitialized session.

If lateConnect is false the transport will be immediatley connected, otherwise it will be connected with the very first request.

If reconnect is true, the transport will automatically attempt to reconnect a socket that becomes disconnected.

Destructor

~Transport virtual

~Transport();

Destroys the Transport.

Member Functions

connect virtual

void connect(
    const std::string & endPoint
);

The endpoint must be in URI parsable format, e.g.: remoting://www.xyz.org:666/path, or remotings://...

See also: Poco::Remoting::Transport::connect()

connected virtual inline

bool connected() const;

Returns the connection status.

See also: Poco::Remoting::Transport::connected()

disconnect virtual

void disconnect();

Disconnects the transport.

See also: Poco::Remoting::Transport::disconnect()

doExecute

void doExecute(
    const Poco::Remoting::Identifiable::ObjectId & oId,
    const Poco::Remoting::Identifiable::TypeId & tid,
    const std::string & methodName
);

Send the request.

doExecuteOneWay

void doExecuteOneWay(
    const Poco::Remoting::Identifiable::ObjectId & oId,
    const Poco::Remoting::Identifiable::TypeId & tid,
    const std::string & methodName
);

Send the request and forget about it. No response checking.

endExecute

std::istream & endExecute(
    const Poco::Remoting::Identifiable::ObjectId & oId,
    const Poco::Remoting::Identifiable::TypeId & tid,
    const std::string & methodName
);

Get the response. Note that even void methods will return at least an empty response except when the method has been flagged as oneway! But in that case the code generator will use doExecuteOneWay instead of doExecute and endExecute.

endPoint virtual inline

const std::string & endPoint() const;

Returns the endpoint this transport is connected to or an empty string if it is not connected.

See also: Poco::Remoting::Transport::endPoint()

getDeserializer inline

Poco::Remoting::Deserializer & getDeserializer();

Returns a Binary deserializer.

getSerializer inline

Poco::Remoting::Serializer & getSerializer();

Returns a Binary serializer.

prepareExecute inline

std::ostream & prepareExecute(
    const Poco::Remoting::Identifiable::ObjectId & oId,
    const Poco::Remoting::Identifiable::TypeId & tid,
    const std::string & methodName
);

Build a request and return the ouputstream so that the serializer classes can append their information to the request.

prepareExecuteOneWay

std::ostream & prepareExecuteOneWay(
    const Poco::Remoting::Identifiable::ObjectId & oId,
    const Poco::Remoting::Identifiable::TypeId & tid,
    const std::string & methodName
);

Build a one-way request and return the outputstream so that the serializer classes can append their information to the request.

Variables

BIN_PREFIX static

static const std::string BIN_PREFIX;

ID static

static const std::string ID;