The Network API was first introduced in BlackBerry® Device Software 5.0 to make network connectivity a breeze for developers. The primary goal of the Network API was to serve two basic use cases:
Detect what transports are available.
Create a connection over one of the available transports.
However, there are a lot of users who may not be running BlackBerry Device Software 5.0 and hence applications are unable to leverage the Network API in those cases. Keeping this in mind, I decided to put together an alternative API with source that developers can use out-of-the-box or extend as they see appropriate in BlackBerry Device Software earlier than 5.0. This open API consists of two simple classes.
TransportDetective: Allows an application to quickly detect what transports are available.
URLFactory: Appends proper parameters to a given URL to connect over a specific transport.
To demonstrate how easy it is to use these classes, here is a snippet that creates a connection over WAP2.
Similarly, you can use other transports such as TCP WiFi, TCP Cellular, MDS, BIS and WAP. Both socket and HTTP based connection URLs are supported including secured protocols such as SSL, TLS and HTTPS.
You may also be familiar with the Network Diagnostic Tool which can be used to quickly test specific transports with a given URL. It is worth mentioning that the latest version of the Network Diagnostic Tool is based on Transport Detective and URLFactory. The source code of this tool is also open. You can download this tool as well as the open Network API today using the links at the end of this article.