SMS Port 0 - plan to compensate for port blocking

17 views
Skip to first unread message

Cristos Lianides-Chin

unread,
Oct 23, 2008, 10:04:59 PM10/23/08
to BlackBerry Industry Developers
A number of our users have noticed that there is a conflict when more
than one SMS-monitoring application is running at the same time.
After discussing it with our partners at RIM, it looks like the
problem is tied to port 0. Whichever application happens to access
port 0 first (when the phone boots) will block all other applications
from listening on it.

After discussing the problem with several of you, as well as our
contact at RIM, we've come up with the following plan to compensate:

* Application "A" launches first when the device boots. It tries to
bind to port 0. Port 0 is available, so "A" successfully binds to it.
* Whenever a message is received on port 0, "A" immediately raises a
global event. That event includes all the information in the original
message (contents, envelope, etc.)
* Application "B" launches later. It tries to bind to port 0. Port 0
is not available, so "B" begins listening for global events.
* When "A" raises a global event, "B" parses the contents and uses
them for normal program function.
* When "A" quits, it raises a global event notifying all listening
applications that port 0 is available.
* All listening applications try to bind to port 0. Only one of them
succeeds. It immediately begins raising global events that include all
the information from the message stream on port 0.
* Etc...

This is currently our second draft, and has one or two open questions
that need to be resolved. In particular, we haven't determined what
happens if the application bound to port 0 unexpectedly terminates.
One option is a "check-in" system, whereby:

* Application "A" (which originally bound to port 0) raises a global
event every second notifying listening applications that it is still
active.
* If listening applications do not catch that global event, then they
attempt to bind to port 0. When one succeeds, it begins sending out a
global event every second, etc...

If anyone has thoughts on the above system, please post a reply to the
group. Also, feel free to invite any other developers or companies
whom you suspect this issue affects.

Best,
~ Cristos
Chief Information Officer
Dexrex, LLC

c...@dexrex.com
http://www.dexrex.com

donal.n.os...@googlemail.com

unread,
Oct 29, 2008, 6:44:18 AM10/29/08
to BlackBerry Industry Developers
Guys,
Here is a post which Mark Sohm submitted a while back
I haven't tried it yet but it sounds like a solution

DatagramConnections also only allow one application to listen on a
specific port. However, you can open a DatagramConnection without
specifying a port (sms://) and listen for all incoming SMS messages.
Multiple applications can listen in this way.

Best Regards

D O'Shaughnessy
mobile development
www.yougetitback.com

Cristos Lianides-Chin

unread,
Nov 3, 2008, 1:34:04 PM11/3/08
to BlackBerry Industry Developers
Hi D,

Have you tried implementing that method in any of your tests? We just
shipped a beta for a client, and haven't had a chance to try your fix
in actual code. However, our CTO read through the post and thought
that it might just default to port 0 (even though not explicitly
defined).

I'll try that snippet out as soon as I get a minute, but was just
wondering if anyone else in the group has already done so.

Thanks,
~ Cristos

On Oct 29, 5:44 am, "doshaughne...@yougetitback.com"

Donal O'Shaughnessy

unread,
Nov 4, 2008, 1:20:15 PM11/4/08
to BB...@googlegroups.com
Cristos
No, I have not yet tried it, Will do so within the next week.
 
Best Regards,
Donal

Cristos Lianides-Chin

unread,
Dec 9, 2008, 3:20:37 PM12/9/08
to BlackBerry Industry Developers
Enlai recently spoke with a developer at RIM who also suggested using
DatagramConnection. Donal, have you had a chance to try using the
method yet?

Thanks,
~ Cristos

On Nov 4, 1:20 pm, "Donal O'Shaughnessy"

Donal O'Shaughnessy

unread,
Dec 10, 2008, 4:32:04 AM12/10/08
to BB...@googlegroups.com
Cristos,
Datagram will receive sms in this way, I am just not sure if multiple apps can listen also
can you perhaps use datagram in your code without specifying the port,
pass on an installation to me with instructions and i will install both on a test device here and test maybe
 
Best Regards
Donal

Richard Tortora

unread,
Dec 31, 2008, 1:13:22 PM12/31/08
to BlackBerry Industry Developers
The DatagramConnection approach only works with incoming texts. If
your application also needs to receive outgoing texts (like Dexrex
does), you will need to use the OutboundMessageListener, which only
works with MessageConnection. MessageConnection requires binding on
sms://:0, which only one app can do at a time.

However, multiple applications can use the DatagramConnection on sms://
to receive incoming texts without issue.

Also check out: http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=7375

On Dec 10, 4:32 am, "Donal O'Shaughnessy"
Reply all
Reply to author
Forward
0 new messages