Creating callback connection established new connection.
Posted: Wed Aug 20, 2014 10:22 am
Hello,
we have an issue with the creation of callback connections as documented in http://www.deltavsoft.com/doc/rcf_user_ ... onnections.
We are working currently with version RCF 2.0.0.2685.
The callback connection makes it possible that a client can be called by the server when a connection from the client to server was established before. This works so far.
But the server and client applications uses two established connections if an additional RcfClient object is made. I have initially thought that the callback connection also uses the already established connection.
So an existing RcfClient with an established connection should be used to create callback connections. The User Guide based code
is changed to
The alreadyExistingClient is still used as a <SomeInterface_Rcf> client with the established connection from the simpleCallToServer method call previously. But this is not possible. It seems that the established connection of the client is lost after the createCallbackConnection statement. If the client is used again as in the last line of the changed user guide code an exception occurred with the following message:
It seems that the ClientStub from client.getClientStub() is destroyed when the method returns to the caller. I have added a line where the client transport is set back into the given clientStub at the end of the method:
With this additional implementation it is still possible to use the RcfClient as the initial client object it was made at the beginning. Additionally only one tcp connection is established for the bidirectional connection on client- and server-side.
But maybe i have missed some point. I am not aware of possible side-effects with the additional statement in the file Marshal.cpp. And i have seen that in Rcf version 2.0.1 the Marshal.cpp method has changed and i have not tested this with this version. But at first look it seems to me that the problem is still there in version 2.0.1.
Kind regards
Falk
we have an issue with the creation of callback connections as documented in http://www.deltavsoft.com/doc/rcf_user_ ... onnections.
We are working currently with version RCF 2.0.0.2685.
The callback connection makes it possible that a client can be called by the server when a connection from the client to server was established before. This works so far.
But the server and client applications uses two established connections if an additional RcfClient object is made. I have initially thought that the callback connection also uses the already established connection.
So an existing RcfClient with an established connection should be used to create callback connections. The User Guide based code
Code: Select all
// Client-side - start a callback server.
RCF::RcfServer callbackServer( RCF::TcpEndpoint(0) );
HelloWorldImpl helloWorldImpl;
callbackServer.bind<I_HelloWorld>(helloWorldImpl);
callbackServer.start();
//Client-side additional code
RcfClient<SomeInterface_Rcf> alreadyExistingClient(( RCF::TcpEndpoint(port) ));
alreadyExistingClient.simpleCallToServer();
// Client-side - create callback connection.
RcfClient<I_HelloWorld> client(( RCF::TcpEndpoint(port) ));
RCF::createCallbackConnection(client, callbackServer);
alreadyExistingClient.simpleCallToServer();
Code: Select all
// Client-side - start a callback server.
RCF::RcfServer callbackServer( RCF::TcpEndpoint(0) );
HelloWorldImpl helloWorldImpl;
callbackServer.bind<I_HelloWorld>(helloWorldImpl);
callbackServer.start();
//Client-side additional code
RcfClient<SomeInterface_Rcf> alreadyExistingClient(( RCF::TcpEndpoint(port) ));
client.simpleCallToServer();
// Client-side - create callback connection.
RCF::createCallbackConnection(alreadyExistingClient, callbackServer);
alreadyExistingClient.simpleCallToServer(); //exception occurred here.
The problem was boiled down to a method in the file Marshal.cpp in the method createCallbackConnectionImpl:OS: 10038 - An operation was attempted on something that is not a socket.
Code: Select all
void createCallbackConnectionImpl(
ClientStub & clientStub,
ServerTransport & callbackServer)
{
RcfClient<I_CreateCallbackConnection> client(clientStub);
client.getClientStub().setTransport( clientStub.releaseTransport() );
client.CreateCallbackConnection();
convertRcfClientToRcfSession(client.getClientStub(), callbackServer);
}
Code: Select all
clientStub.setTransport(client.getClientStub().releaseTransport());
But maybe i have missed some point. I am not aware of possible side-effects with the additional statement in the file Marshal.cpp. And i have seen that in Rcf version 2.0.1 the Marshal.cpp method has changed and i have not tested this with this version. But at first look it seems to me that the problem is still there in version 2.0.1.
Kind regards
Falk