Socket Programming on BlackBerry - blackberry

I am stuck creating a socket connection between blackberry client and java server. I need simple sample code which extends the socket API example from blackberry sample code.
We have a server that communicates with android systems and we need it to work with blackberry client as well.

Sorry for being late. And I am posting my comment here because of comment length. _screen.isDirectTCP() isn't an API method, so I am not sure what does this method return. But from the method name/signature I think this method is only used for checking whether Direct TCP connectivity is available or not on the device. Depending on the result, the application will append the connection parameter such as ";deviceside=....".
From the Network Transport article,
If you do not want your application to rely on the default connection
types described in the previous sections, explicitly state the
desired connection type by adding the “deviceside=” parameter to the
destination URL. If an application appends “;deviceside=true” to the
destination URL, then only a direct HTTP or TCP connection is
attempted. The application does not attempt to connect to the network
using the BlackBerry MDS. Alternatively, if an application appends
“;deviceside=false” to the destination URL, then the application only
attempts to connect to the network using the BlackBerry MDS. The
application does not attempt to connect to the network using a public
IP gateway.
Also please have a look at this link, What Is - Different ways to make an HTTP or socket connection.

Related

Difference between App Proxy Provider and Packet Tunnel Provider

I'm reading the documentation of the App Proxy Provider and the Packet Tunnel Provider and am a bit puzzled.
The docs state that packet tunnel providers send and receive packets from/to the system, while app proxy providers send/receive flows to/from the system.
What's confusing from the packet tunnel provider documentation:
Packet tunnel providers can run in destination IP mode or source-application mode. The latter is one form of per-app VPN (the other form is an App Proxy Provider).
But in the NETunnelProvider class it says:
The default is NETunnelProviderRoutingMethodDestinationIP.
So by default, the Packet Tunnel Provider is actually an App Proxy Provider? What am I missing? Could someone explain their difference?
The AppProxy and PacketTunnel are options to implement VPN.
The AppProxy works with so called Flow objects, each flow is started by some application. AppProxy receives the flow and forward it to somewhere.
The PacketTunnel works with packets. It receives the packet and could do something with it (like, modify) before it goes to the network.
Now, the part of documentation may causing you troulbes relates to the question: what exeactly flows/packets do AppProxy and PacketTunnel receives?
AppProxy:
The NEAppProxyProvider class provides access to flows of network data
in the form of NEAppProxyFlow objects. Each NEAppProxyFlow object
corresponds to a socket opened by an app that matches the app rules
specified in the current App Proxy configuration.
That means, you will have all flows matches your rules go to your class method first, and then routed to some new address.
PacketTunnel:
Packet tunnel providers can run in destination IP mode or
source-application mode.
That mean, you can set the rule like "each packet that goes to "list of ip addresses", I want you to go through my class method and then into the tunnel" - and this will be destination IP mode.
Or you can set the rule like "all packets from app with bundle id com.my.app now go to my class method first and then into the tunnel" This is source-application mode.
This (the source application mode of PacketTunnelProvider) is one of per-app VPN forms, because it focused on the application, that produces traffic.
The AppProxy also focused on application that produces traffic, so it is the other form of per-app VPN, but it will give you the flow object app produces, not the packets with ip and tcp/udp headers.

Framework for communicating between iOS and MacOS

I'm looking to build a pair of apps that work in a similar way to iTunes and the Remote app for iOS... Is there a framework for connecting iOS and MacOS over wifi?
Bluetooth is something I'd like to avoid and there's no need for a web service, I'm just looking to control my Mac app remotely from the phone.
Thanks in advance.
Id say the most ideal way to accomplish this is via the Bonjour protocol.
Here is a great article on the subject, http://mobileorchard.com/tutorial-networking-and-bonjour-on-iphone/.
Good thing with using Bonjour in iOS is it also works via Bluetooth.
Hope this helps !
here is an example project which exchange the data between iphone and iMAC with WiFi connectivity.
https://github.com/boobalaninfo/Bonjour-iOS-MAC-Apps
Use bonjour to search for devices. Then use CocoaAsyncSocket to send and receive data. It works like a charm.
Little info about AsyncSock:
GCDAsyncSocket and AsyncSocket are TCP/IP socket networking libraries.
Here are the key features available in both:
Native objective-c, fully self-contained in one class. No need to muck
around with sockets or streams. This class handles everything for you.
Full delegate support Errors, connections, read completions, write
completions, progress, and disconnections all result in a call to your
delegate method.
Queued non-blocking reads and writes, with optional timeouts. You tell
it what to read or write, and it handles everything for you. Queueing,
buffering, and searching for termination sequences within the stream -
all handled for you automatically.
Automatic socket acceptance. Spin up a server socket, tell it to
accept connections, and it will call you with new instances of itself
for each connection.
Support for TCP streams over IPv4 and IPv6. Automatically connect to
IPv4 or IPv6 hosts. Automatically accept incoming connections over
both IPv4 and IPv6 with a single instance of this class. No more
worrying about multiple sockets.
Support for TLS / SSL Secure your socket with ease using just a single
method call. Available for both client and server sockets.

Check Worklight Client connection state

I'm working on a native iOS app that is using IBM Worklight server adapters, in my code every time I want to invoke a procedure I'm calling the WLClient().wlConnectWithDelegate(self) and then calling the adapter, is there a way that would let me check the connection status of the client before I invoke the adapter procedure?
There is no such API provided by the Worklight framework.
The idea behind the connect API is to establish a session between the client and server, negating the possibility for example of race condition (such as two adapter requests to the server, each getting its own session, potentially causing trouble), in addition to delivering data on headers that is no available in an adapter request compared to connect request.
I think that instead of making a connect request before invocation you can do it in an early stage in the app's lifecycle, as well as whenever the app returns to the foreground, to ensure that a session was established. This, coupled together wit an appropriate session timeout set in worklight.properties on the server-side.
More here: https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-0/hello-world/connecting-to-the-mobilefirst-server/

How to make iOS believe there is Internet Connectivity

I am working on a web application for iOS that is going to be accesed from a local webserver in a network that has NO internet connectivity at all.
My problem is that everytime an iOS device is locked, it disconnects from the WiFi network, so when the device is unlocked again, it has to reconnect. Part of that reconnection process is determining if there is Internet connection (which there isn't). Until the process is not finished iOS does not allow any DNS resolution (so if I write http://10.0.0.1 it will go there, but not if I request http://something.local.com).
Since we control that network, we want to know how to does iOS verifies Internet connectivity so that we can fake the responses it expects.
I don't know if it's possible to resolve DNS without an internet connection on iOS, but if that's the case, that would be a way better solution since you don't need to mess with your router settings. Use my solution only if it really isn't possible with only code.
I'll suggest you to follow this guide: http://blog.jerodsanto.net/2009/06/sniff-your-iphones-network-traffic to check which actions your iPhone executes to detect an internet connection.
Using this information you could forward the is-there-internet-requests on your router to a local server which fakes the there-is-internet-responses.
This assumes Apple really uses an external server to detect this, which I'm not sure about. But it wouldn't hurt to give it a try!
Have you looked at the Reachability Class? You don't have to use the reachabilityForInternetConnection method, which checks if a default route is available. You can use the reachabilityWithAddress: method and check if your server is reachable.

Query related to Connection type BIS-B Socket in Blackberry application

I am trying to establish BIS Socket connection. I am able to establish BIS Http connection from my service provider.
I have downloaded one chat application that checks network types supported by my device/service plan which has following list:
1)BIS-Http : OK
2)BIS-SOCKET :OK
3)BES-HTTP : NA
4)BES-SOCKET : NA
5)TCP-HTTP : BAD DNS
6)TCP-SOCKET : TIMED OUT
As I know direct TCP is not supported by my service provider. So I would like to use BIS-Socket connection.
Can anypne please help me in achieving this type of connectivity?
Use of BIS-B connectivity is available to members of the Blackberry Developer Alliance program. Not being a member I can't tell you if if supports random socket connection or not.
Normal BIS access available through the API supports web protocols and is not a TCP/IP protocol between the Blackberry and the BIS. Hence the deviceSide= parameter in the connection stream. DeviceSide=true the Blackberry uses an internal TCP stack to establish a connection through direct access to the wireless carrier's access point (APN). DeviceSide=false (the default) the Blackberry sends the necessary data to the BIS (or BES) MDS server using a presumably proprietary protocol. The MDS server then establishes the TCP connection on behalf of the Blackberry.
If direct TCP is not available to you, and you can't use BIS-B, you will have to carry your data on top of an http connection. In most cases this is straight forward and works quite well.
To use BIS you need pay $2000. Have you done that? how you know you're using BIS?

Resources