Want to optimize the http-connection in Blackberry(J2ME or LWUIT or RIM).
I am using the connection object this way:-
HttpConnection c=(HttpConnection)Connector.open(url);
I thought of using connection pool, but the problem is the url varies.
Optimize- Using the same connection object so that the code works more efficiently
Connector.open doesn't work properly on the blackberry and had inherent issues in LWUIT. CodenameOne's networking layer includes special support for RIM solving networking on that device.
In my application i add the requast to Queue of class Network Manager that responsible on connection in Lwuit (I can't create http connect,all done by lwuit). about optmaize you can use unsynchronizrd function that will be load the new connection on the instance only if the respone will recievd or that connection be finishe, But i think that is "recipe" for problems.
Related
I want to stream audio file between to multiple device, one act as server and other as client on the local network, I found https://github.com/tonyd256/TDAudioStreamer this class that stream audio to connected client but it use multiplier connectivity. I wonder that, can I use this class with GCDAsyncSocket or NetService if there is any way?
as my experience you have to pass stream object to this classes in order to work with GCDAsyncSocket or NetService. Then after client side receiving data from server you have to convert that data in proper format to play.
That's all i know.
Does blackberry framework use connection reuse for http connection? I use connectionFactory.getConnection("api.abc.com") . I have noticed that the first call (simple rest call for ex, getting number of unread messages) from my app takes about 4 seconds but all the subsequent calls take less than a second to complete. I have noticed that the same call when made after another call takes less than a second, so I am thinking that blackberry uses http connection reuse. Does anyone have an explanation for this behaviour?
You can test this on the server, by looking at the network activity that actually makes it to the server. My own testing indicates BlackBerry devices do not re-use connections.
I'm wondering if someone could point me in the right direction for this problem. A bit of introduction:
In an app we maintan we just rewrote our network layer to remove support for OS 4. We're using the cleaner ConnectionFactory provided in OS 5. Please note the issues we're encountering are device-only, not simulator related.
There are two ways or app has connectivity, a data thread that polls specific urls and stores data, and a "generic web view" (a BrowserField).
So far it seems there's no problems with the data thread connectivity, it properly builds the urls based off transport type and downloads the data correctly. In the BrowserField we have a different problem. There's an OS 6 curve causing problems (no other OS 6 device though) when we open the BrowserField with a URL there's a chance it will show a "Could not select proper transport descriptor" message - the most common culprit is WAP2.
I guess we're a bit baffled that BlackBerry doesn't seem to handle the transport descriptor choosing as well as we had hoped. Does anyone have any recommendations?
Due to its length, I've posted our connection utility class on gist: https://gist.github.com/3490101
The most common connection form, used by the data thread, is the getUrlAsString(String etag) function, which does a GET and caches the response based off the etag/url.
To build URLs for our BrowserField we use the buildURLTransport(String url) function, which gets a connection on the url, determines the transport information, and returns the built URL.
TL;DR: There's an oddity in a BrowserField we can't seem to debug, we'd appreciate a new set of eyes: we think there's something wrong in the above posted gist in the buildURLTransport(String url) function.
Thanks a tonne in advance.
Be careful with your code because getUrlAsString isn't thread safe. I didn't understand why you keep reference to the ConnectionFactory sometimes why you don't for other.
I aslo didn't understand why do you need method buildUrlTransport. Why don't use BrowserFieldConfig together with ConnectionFactory for BrowserField as here.
So I would instantiate one ConnectionFactory, configure it with your specific parameters and use it everywhere. In case of preferences change I would recreate ConnectionFactory and update BrowserFieldConfig. Sure this code should be thread safe.
Also be more consistent - sometimes you use quick connection check, sometimes you don't.
I am learning C and Objective-C so am still dependent on examples...
I found AsyncUDPSocket which has a lot of example code in the Google Code repository, but I'm not far enough along to understand it all yet.
I'm trying to build an iPhone app that uses UDP for communication to another device (Arduino). I have the device end working (testing with the UDP Tool app). I just need help with the iOS side of it...
An example with more explanation would really help (that is, a tutorial)... Is there one or what would some example code with good comments be?
https://github.com/robbiehanson/CocoaAsyncSocket
GCDAsyncUdpSocket and AsyncUdpSocket are UDP/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 low-level sockets. This class handles everything for
you.
Full delegate support.
Errors, send completions, receive completions, and disconnections all result in a call to your delegate method.
Queued non-blocking send and receive operations, with optional
timeouts.
You tell it what to send or receive, and it handles everything for you. Queueing, buffering, waiting and checking errno - all
handled for you automatically.
Support for IPv4 and IPv6.
Automatically send/recv using IPv4 and/or IPv6. No more worrying about multiple sockets.
I want to get the data about when a connection from the device is established, when the connection is terminated and how many bytes were transferred (in/out).
I couldn't find proper listeners in the BB API. I found application that does this and I am wondering how this can be implemented?
You could take a look at the RadioInfo class - there are methods in there such as getNumberOfPacketsReceived() and getNumberOfPacketsSent() that might do what you want.