File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Socket: Information Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Socket: Information" Watch "Socket: Information" New topic
Author

Socket: Information

Shyam Prasad Murarka
Ranch Hand

Joined: May 02, 2005
Posts: 209
Hi Ranchers,
My seniors have assigned me the task of making a Scrabble game for our cultural fest website. They want it as a Java applet.
I am thinking of making it using Sockets. I have previously made a Chat application based on Sockets. I also tested it on LAN and it seems to give no problems. I have never tested it across a Net connection.
I have very recently come to know that Sockets will NOT work across Net because of some direct connection or something. I am not too sure on that concept. Do you guys have any idea what that was supposed to mean?
Also, my seniors told me that all ports except 8080 in our college were blocked for communication.
So imagine a scenario where I have made the game and (just for now) its working on Sockets. Can I make the Java Scrabble Server listen on port 8080 provided our normal college Net traffic also goes through that port? Or is only application (in this case the Net connection) allowed to sit on a particular port?

ALternatively, I was thinking of using RMI. Will that be possible? I am kind of rusty on RMI right now, but do we have to provide IP Address and port number when working through RMI also?

Lastly, my senior suggested that I use PHP for client side and transfer the data into the server database. And the Java Scrabble Server will have to perform routine checks on the database for further processing. Will that not result in a time-lag? Is it a good idea?

I may not have been clear on my Socket problem, so if anyone requires further explanation, do let me know.


With Best Regards,
Shyam Prasad Murarka
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
1) You can use sockets in an applet, as long as it connects back to the same server that the applet is hosted on. In other words, you can't use them to connect to any particular other client, just the server. But since you're talking about having a server anyway that should be no problem.

2) The bigger problem is port 8080. That's commonly used for HTTP (i.e. web traffic), so there's likely to be a web server listening. Since there can only be a single process listening to a particular port, you can't use it for your server, unless that server is a web application on that web server. In which case the client wouldn't use sockets directly, but the java.net.HttpURLConnection class (or a library like Apache Commons HttpClient).

3) PHP is not a client-side technology - it's server-side. Did he mean that you should program the client in HTML/JavaScript (possibly generated by PHP) instead of an applet? That's certainly a possibility. In that case, the communication to the server would probably be through AJAX, in particular the JavaScript XmlHttpRequest object.


Ping & DNS - updated with new look and Ping home screen widget
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3169
    
  10
Originally posted by Shyam Prasad Murarka:
My seniors have assigned me the task of making a Scrabble game for our cultural fest website.


I hope you've got permission


Joanne
Shyam Prasad Murarka
Ranch Hand

Joined: May 02, 2005
Posts: 209
Hey Joanne Neal, thanks for the link. God, I never knew that such a racket was in motion. But, I guess our website would be too small to be noticed. It will be mostly only for the college people and that too it will be hosted for a short time period. Hopefully no problems crop up or I shall see my photo in BBC News (which would be awesome)


Originally posted by Ulf Dittmer
3) PHP is not a client-side technology - it's server-side. Did he mean that you should program the client in HTML/JavaScript (possibly generated by PHP) instead of an applet? That's certainly a possibility. In that case, the communication to the server would probably be through AJAX, in particular the JavaScript XmlHttpRequest object.


Yes, I had meant using HTML/Javascript for client-side whereas PHP as the server-side processor.
But, will it be feasible to store information received from client in a text file using PHP and having Java to regularly scan that file for updated status of the game? Is there any other workaround? Like somehow letting Java know each time new information comes in through PHP?

Thanks for the information.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
I know nothing about Java/PHP integration, but if the frontend is generated by PHP, why not use it for the backend as well? Seems easier than some hybrid server.

Alternatively, if the server is supposed to be in Java, why not use servlets/JSPs for generating the frontend?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Socket: Information
 
Similar Threads
Sockets vs. RMI
Custom Proxy server handling both http and https?
RMI vs Socket?
Scrabble... it only takes a minute...
Use of sockets through RMI