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

Java Development

Reply
Developer
Posts: 149
Registered: ‎03-09-2009
My Device: Not Specified

Re: Reusing Socket Connection

Thank for your time,

 

Strangely it's seem that my problem is "ClObjConnexion.instance().GetOutput().flush()". I remove this line and now I can talk with server back and forth with the same local adresse and port. The problem now reside in my socket service on my server. It grab the communication, return the OK response and after the first one, do nothing...

 

Thank again,

Pascal Bourque, Analyste-Programmeur : "je pense donc je programme"
Really want to thank a user? Click the Kudos! badge on right side of the message. When you do so, you are offering a thumbs up for good content and a pat on the back to its author.
Accepted Solutions is a way for you to choose the reply that best answers a thread that you've started. To mark a message as a solution: Click the Solution? icon on the reply.
Developer
Posts: 51
Registered: ‎07-15-2008
My Device: Not Specified

Re: Reusing Socket Connection

 

hi,

 

i am also facing the same issue.

 

I want to have persistent socket connection for longer period of time.

 

have you got the above code working ??? 

 

please elaborate more how u find your final destination and also help me out....

 

thanks in advance....

 

Developer
Posts: 149
Registered: ‎03-09-2009
My Device: Not Specified

Re: Reusing Socket Connection

Hi,

 

Here de solution, it doesn't work at all !

My only advice is : Don't use socket, BB Doesn't know to manage it correctly.

 

Use http, mail or pin message to bypass this.

 

Hope it will anwser to your question.

Pascal Bourque, Analyste-Programmeur : "je pense donc je programme"
Really want to thank a user? Click the Kudos! badge on right side of the message. When you do so, you are offering a thumbs up for good content and a pat on the back to its author.
Accepted Solutions is a way for you to choose the reply that best answers a thread that you've started. To mark a message as a solution: Click the Solution? icon on the reply.
Developer
Posts: 19,624
Registered: ‎07-14-2008
My Device: Not Specified

Re: Reusing Socket Connection

I don't completely agree with the statement:

"Don't use socket, BB Doesn't know to manage it correctly."

 

I do agree with is that the BlackBerry device does not manage a persistent socket connection over wireless connections well - though to be honest I'm not sure if that is a function of the wireless network of the device itself.  But anyway, typically a persistent connection is a bad idea and of little value.  Unless you are exchanging data, you are better using push as a notification method. 

Developer
Posts: 149
Registered: ‎03-09-2009
My Device: Not Specified

Re: Reusing Socket Connection

@peter_strange

I blame BB you blame de method but who let using the method ?

 

Push method is a good method for RSS kind but for another level of development you need to communicate with the application to know what's going on the cellphone.

 

When you need to ensure if the cellphone is ok you need an answer and the BB can answer correctly by pin, mail and http in this order of efficacity. If you have another perseption in the communication between a server and un group of cellphone, i'll glad to learn more.

Pascal Bourque, Analyste-Programmeur : "je pense donc je programme"
Really want to thank a user? Click the Kudos! badge on right side of the message. When you do so, you are offering a thumbs up for good content and a pat on the back to its author.
Accepted Solutions is a way for you to choose the reply that best answers a thread that you've started. To mark a message as a solution: Click the Solution? icon on the reply.
Developer
Posts: 51
Registered: ‎07-15-2008
My Device: Not Specified

Re: Reusing Socket Connection

hi guys

 

i search over the forums again and again but didn't  find  any useful solution for my prob :smileysad:

 

I am using persistent socket connection by opening input stream open for infinite time and for this reason battery  drains out pretty quickly  which i want to avoid.....

 

 

plz give some kind of solution since coz of my requirements can not use push APIs...

 

thanks in advance....

 

 

 

 

 

 

Developer
Posts: 149
Registered: ‎03-09-2009
My Device: Not Specified

Re: Reusing Socket Connection

Hi yog123,

 

Here my workaround (not the best, not the worst)

 

Stop using persistent socket connection, for multiple reason, and use http connection with a web service that can handle request and response. In this way you will be able to make a connection back and forth.

 

I don't know if your requirements autorize http but if your exigences tell to use socket, I think you will need to leave up your chair and tell to your client, or boss, he goes on the wrong way...

 

Only my opinion, but what I'm sure is not all roads lead to rome...

Pascal Bourque, Analyste-Programmeur : "je pense donc je programme"
Really want to thank a user? Click the Kudos! badge on right side of the message. When you do so, you are offering a thumbs up for good content and a pat on the back to its author.
Accepted Solutions is a way for you to choose the reply that best answers a thread that you've started. To mark a message as a solution: Click the Solution? icon on the reply.
Developer
Posts: 51
Registered: ‎07-15-2008
My Device: Not Specified

Re: Reusing Socket Connection

[ Edited ]

Hi ,

 

I still not getting success either with persistent socket connection or with BlackBerry Push Service.

 

During searching this stuff , was wondering how chat applications in BB work like Btalk ?? Can anybody have clear focus on this one ... 

 

I want to listen for my data on one socket provided by server.

 

Suggestions welcome !!!!!

Developer
Posts: 19,624
Registered: ‎07-14-2008
My Device: Not Specified

Re: Reusing Socket Connection

Sorry I have not reviewed all the preceding discussion.

 

A persistent socket connection is one that is open all the time.  You do not use a persistent socket connection with the Push service.

 

Instead you have a Listener that waits for a PUSH request from the Server.  This is what the push service does, so you have a Thread that uses

<StreamConnectionNotifier>.acceptAndOpen()

 

This will get notified and can get some data when the Server pushes it.

 

I recommend that you should investigate the PUSH service rather than attempting to continue doing what you are currently doing. 

 

There is sample code provided for this service and many forum entries that discuss it.