This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi Ranchers, My seniors have assigned me the task of making a Scrabble game for our cultural fest website. They want it as a Javaapplet. 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.
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).
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)
Thanks for the information.
Joined: Mar 22, 2005
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?