Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
renjini
Posts: 24
Registered: ‎11-05-2012
My Device: BB10
My Carrier: Airtel

Can application (A) and (B) share their data?

Hi,

 

Using cascades , Can application (A) and (B) share their data?

 

Regards,

Renjini.

Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Can application (A) and (B) share their data?

Hi,

There are multiple options depending on what you need to do:

- Write the data to a file in shared folder.

- Use Invocation framework to invoke the application from another one.

- Use sockets to transmit data between applications.

Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Contributor
renjini
Posts: 24
Registered: ‎11-05-2012
My Device: BB10
My Carrier: Airtel

Can application (A) and (B) share their data?

Hi,

 

Thanks for your reply,

 

Could u send any documentation or sample code to transmit data b/w application using sockets.?

 

Thnaks & regards,

Renjini.

Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Can application (A) and (B) share their data?

[ Edited ]

In Qt there's QTcpSocket & QTcpServer classes. Server application listens on some arbitrary port and client application connects to it.

 

TCP requires establishing a connection first. It guarantees reliable delivery of data.

 

Also there's QUDPSocket for connectionless sending of messages. When using UDP you can send packets of up to 64 kb in size, but the delivery order and the delivery itself is not guaranteed.

 

 

TCP server example:

http://qt-project.org/doc/qt-4.8/network-fortuneserver.html

 

TCP client example:

http://qt-project.org/doc/qt-4.8/network-fortuneclient.html

 

Basically any Qt examples will work, google "QTcpSocket example" for more examples.

 

If you don't want to allow apps from outside network to connect to your app, bind the server socket to a local interface (127.0.0.1).

 

It's also possible to broadcast the message to the entire network or send a multicast message to a group of recipients. Check broadcastsender & broadcastreceiver projects for an example of broadcast:

https://github.com/blackberry/Qt2Cascades-Samples

  

For communicating between two local apps I'd probably pick TCP or UDP.

Also Invocation Framework might be better for some tasks as it can launch the target application if it's not running.

 

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.