powered by Jive Software

Smack''s blocking API: how to avoid this behaviour?

Hi,

I’‘m trying to port smack to J2ME and succeeded EXCEPT for one issue: getting rid of Smack’'s blocking API. The problem is that Smack depends on sockets that support simultaneously reading and writing from/to a socket (also called full-duplex sockets). I have an IM client that runs on every J2ME emulator you can think of, but on not one REAL phone. The problem is that there are not many phones available that support full-duplex sockets.

I had a long discussion with Mariano a while ago how I could solve the problem, but our conclusion was that it might very well be impossible. Read the conversation here:

Now some time has passed and I went back to the project. There’'s a lot of interest in it, certainly with the increasing popularity of XMPP. I still think it would be great if Smack was available for J2ME phones (the majority within a short time). BUT BUt But but…that still requires me to solve that last killing problem of full-duplex sockets.

I guess my question is whether someone else here has any idea how we could avoid this blocking behaviour and finally get Smack working on a real Java phone.

My gratitude would be huge!

Cheers,

Berco

Berco,

One idea – what if you used the HTTP polling spec to check for new content from the XMPP server: http://www.jabber.org/jeps/jep-0124.html

This would only work on a subset of servers, of course.

Regards,

Matt

Hi Berco

Doing a Google, I found this:

http://www.handango.com/ampp/store/PlatformProductDetail.jsp?&siteId=1208&catalo g=0&sectionId=0&productType=2&platformId=4&productId=118510

It looks like the Nokia 6600 supports full-duplex socket connections. I believe other handsets will be the same, only a matter of time.

Keith

Hi Berco

I ran an exercise yesterday to port the latest 1.4 smack library to J2ME. All was fine except for:

  • StringTokenizer (used Sun’'s class for now)

  • SimpleDateFormat (commented out the code for now)

  • Reflection (read below)

The reflection code for the event notification was easily ported to call the methods explicitly. The 2 parts that I couldn’'t do was parsing the XML via introspection, and streaming the property.

I will be doing some testing on this library. If anyone is interested in it, let me know.

Keith

Hmm…that link doesn’'t work…

Indeed, some phones support full-duplex. Nokia 6600 is indeed one. But there are only a very few that do and in practice its a showstopper.

Cheers,

Berco

Hi Keith,

Interesting! I would certainly be interested in the testing. Did you actually get it to work? Did you see the list of issues when porting I posted to this list earlier? There are definitely more than just the three you mention.

Please keep me informed.

Cheers,

Berco

Hi Berco

Yes, the 3 are in addition to the ones you posted.

Testing is going well, I got logon, chat and messaging working on WTK2.1.

Once I have tested it more thoroughly (using real phone), I will upload the library for you.

PS: Yeah, the link is broken. Weird. Anyway, it’‘s nothing you already don’'t know.

Regards

Keith

Hi Keith,

Thanks for the fast response!

I guess Smack 1.4 still is a blocking API (still relies on full-duplex sockets), so you will run into the same problem I ran into; that such sockets are close to none-existent on real phones.

Currently I’‘m experimenting with a serverside J2SE proxy that takes 2 sockets (read and write) from a J2ME Smack client and ties them to one full-duplex socket to a jabber server. I’'ll post the results here.

Cheers,

Berco

The 2

parts that I couldn’'t do was parsing the XML via

introspection, and streaming the

property.

Sounds familiar. Object serialization is not available in J2ME. Unfortunately, else it would mean we would have RMI on J2ME as well

Cheers,

Berco