How to creat a J2Me chat client for a PHP website

Java programming topics
Post Reply
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

How to creat a J2Me chat client for a PHP website

Post by Rksk » Tue Sep 13, 2011 12:00 am

I'm finding a way to build a chat client in j2me for a php based website. Can anyone help me?

Googled and nothing found useful.

Also read below topics. But didn't get idea.
https://robot.lk/viewtopic.php?f=11&t=1852
https://robot.lk/viewtopic.php?f=11&t=1925
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: How to creat a J2Me chat client for a PHP website

Post by Neo » Tue Sep 13, 2011 12:08 pm

From my understanding, php and j2me has no direct interaction. If that is the case, what you output with php is what you seen on the browser. So in simple terms, you will have to output required JavaScript/ HTML-Java class, etc... from the php code which the client (browser) will see as the output.

Alternatively, you can directly use AJAX (asynchronous JavaScript and XML) if not specific to a mobile browser. This is the best known way to create chat engines for the web. With this method you can update part(s) of the page without refreshing the whole page. w3school's AJAX Tutorialis very good.
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: How to creat a J2Me chat client for a PHP website

Post by Rksk » Tue Sep 13, 2011 2:58 pm

No no. I want to create a j2me client (for mobiles phones) for my own php site. It's very easy to code the php site. But I don't know how to connect to website using j2me and how to hadle connections using php. I think it will use Socket connection. Because http connection isn't suitable for a chat client because of we have to relord always.

[ Post made via Mobile Device ] Image
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

Re: How to creat a J2Me chat client for a PHP website

Post by Saman » Tue Sep 13, 2011 3:45 pm

Here is a way to interact between J2ME and PHP. See How to interact J2ME with PHP.

You might also look at PHP Interacting with J2ME article at Dev Articles.
I think it will use Socket connection. Because http connection isn't suitable for a chat client because of we have to relord always.
Sockets are the underlying layer in network communication. Even HTTP, FTP like protocols are also using sockets. A socket is associated with a IP and Port. If you take a web server, it works on a specific IP and Port 80. In other words, when you a HTTP POST or GET, the system internally use sockets to fetch data through Port 80. If you are going to host on a shared server, you are not allowed to use ports other than 80 (HTTP), 21 (FTP) and a few more (POP, SMTP, IMAP, SSH, SFTP, etc..). So in most cases, you need to design your chat server to work with HTTP POST/GET.

So from J2ME, it would be a HTTP POST or GET to the PHP page. As Neo stated on AJAX, you can use AJAX directly without J2ME. However it would be browser based. If you want an application (a client), then you will have to J2ME. Make sure one design aspect. Most of the servers are limited to handle only a few simultaneous connection. Good hosting companies provide about 20. So you will have to take care on that. In other words, if you have about 100 users chatting at the same time, shared server might not handle this. That is why dedicated servers (or with good VPS) are usually used for mass scale chat systems.
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: How to creat a J2Me chat client for a PHP website

Post by Rksk » Tue Sep 13, 2011 11:03 pm

Saman wrote:Here is a way to interact between J2ME and PHP. See How to interact J2ME with PHP.

You might also look at PHP Interacting with J2ME article at Dev Articles.
I think it will use Socket connection. Because http connection isn't suitable for a chat client because of we have to relord always.
Sockets are the underlying layer in network communication. Even HTTP, FTP like protocols are also using sockets. A socket is associated with a IP and Port. If you take a web server, it works on a specific IP and Port 80. In other words, when you a HTTP POST or GET, the system internally use sockets to fetch data through Port 80. If you are going to host on a shared server, you are not allowed to use ports other than 80 (HTTP), 21 (FTP) and a few more (POP, SMTP, IMAP, SSH, SFTP, etc..). So in most cases, you need to design your chat server to work with HTTP POST/GET.

So from J2ME, it would be a HTTP POST or GET to the PHP page. As Neo stated on AJAX, you can use AJAX directly without J2ME. However it would be browser based. If you want an application (a client), then you will have to J2ME. Make sure one design aspect. Most of the servers are limited to handle only a few simultaneous connection. Good hosting companies provide about 20. So you will have to take care on that. In other words, if you have about 100 users chatting at the same time, shared server might not handle this. That is why dedicated servers (or with good VPS) are usually used for mass scale chat systems.
Thank you very much Saman.

I didn't know that port problem (with shared hosting).

[ Post made via Mobile Device ] Image
Post Reply

Return to “Java Programming”