Unless you are using a very restrictive ISP, ofcourse you can.
Your users likely won’t have great connectivity, though. I would recommend a VPS (virtual private server). Both SliceHost and Linnode have plans starting at US $20/mo, with enough memory/bandwidth to get you started (and you can always upgrade, or get more nodes, if you need). You have full control over your node/slice and have the option of several different Linux distros to install. At any time, you can wipe it and start over with a fresh install in a matter of minutes using the tools they provide. The support is top-notch (especially at SliceHost) and there are plenty of resources to help with setup and maintenance. If you need to run multiple nodes, Linnode will exclude internode bandwidth usage from your total.
I’ve got a VPS with SliceHost that I’ve been using for personal stuff for a few months now and have no complaints.
Most ISPs that I know of will allow this on a technical level, but prohibit any sort of server running at the TOS level, and reserve the right to shut you down if they notice (Comcast definitely does this). Fios is the only exception I know of (for the lucky few that have that option), unless you get a business plan from your provider.
Wow, US ISPs must realy suck?!
Unless you are trying to operate a commerical website through a residential broadband connection, ISPs here in the UK generally don’t care what you do - so long as you don’t exceed whatever your bandwidth cap is.
As far as I know on Comcast (my US ISP) I can host whatever the hell I want.
Bandwidth cap? Gee, ISPs in the UK must really suck. We generally have unliminted bandwidth here (at least today…)
Seriously though, hosting at home is fine as a development experiment, but if you’re at all successful it results in your home machine becoming unavailable to you. Limited or not not, you probably have pretty low reliability, low speed, and high latency compared to a regular service provider.
check out i think its vps-link or something like that, google them. a small vps server is only 7 bucks USD a month for 64 ram, a good amount of bandiwdth and enough space, then if your server does get that traffic and makes your bandwidth go sky high, you can upgrade it. Whats great about vps servers is you pick your operating system, putty into it and do whatever you want, install java, mysql, tomcat, etc… and vps link is very good and the cheapest around. I currently have a plan with them right now, i managed to run it using lighttpd mysql sendmail all under 64 ram sql takes up a heck of alot.
Hi
We use The Planet, got root access (we even changed the distro on our server), we have a numer of websites, game servers, email server etc, anything we want. Our server costs something like $80 USD a month for 1500GB of bandwidth, it’s quite an old machine (celeron 1.7) and we upgraded the RAM, but it woks nicely.
HTH
Endolf
Just pay some of the tech guys at your nearest university, and place your little server under someone’s table there, and enjoy their (usually) awesome bandewith
wow all great ideas. i might look into the university thing since i currently attend the university of texas. although while on the subject of networking i have one quick question.
my game is turn based thus data is not constantly sent back and forth between the two games. However, is there a good way to show animations while waiting for data to come in? to be more specific the applet alone has a run method that (without networking) handles gameplay. However, i have come to learn that putting code in the existing run method for networking causes the run method to stop while waiting for data to come in. thus my question is whats the best way (or is there a way) to allow animation to continue and wait for data to come in at the same time?
i tried creating a second thread that just looped on in.readLine(); but this just made things screwy.
For turn based you can easily use event based triggering, listener etc.
To trigger events on the event dispatcher thread use Eventqueue.invokeAndWait() This should allow you to avoid most of the complexityeffort involved with multi threading. You just need to focus a bit on managing the ‘remote game’(network connection). Creating your own eventqueue isn’t that difficult either if you do all the drawing you self - but since it’s turn based your probably not using active rendering.
Oh and looking at executors is always a good idea, though with the event based approach you won’t need it on the client. server-side it might work out depending on your approach.
i am using active rendering however im still relatively new to java so i dont quite understand the eventqueue you mentioned. could you explain it a little more fully or is there a good site with some reading on this subject?
Eventqueue is a way to have inter thread communication where no thread ends up waiting for one an other at the sacrifice of the ‘sending’ thread not knowing exactly when the other thread notices it.
A real life example is the mail-man and you, you might never see the mail man but you do receive mail. This is because you have a mailbox which you occasionally check. Since you don’t have face to face contact you never have to wait for the other to be ready to receive. (in other words synchronise yourself with the mail-man) Other analogy would probably be ‘just leave it on my desk if I’m not there’.
Depending on where you want the code(/logic) to reside you can either submit runnable’s or events to a ConcurrentQueue. Or hybrid approach off-course (event containing a runnable).
It all sounds harder then it actually is, trust me.
If you want to read something I gues there is http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ConcurrentLinkedQueue.html (theres a link to a paper there, haven’t read it, but it might give you some pointers) judging from that page the magic word is ‘wait-free’.
your right that does sound difficult lol. so would i have two threads or just one? so is eventQueue just a way of handling multiple threads without using synchro?
if not maybe a little example code would help if its not too much trouble…
code needs some work to actually show the simplicity of it - my apologies was pulling an all-nighter and at the end I though I might type out this as well. :
The idea is that you can simply share the queue with both threads and safely call add() and poll() all synchronizing happens through the queue allowing to pretty much not care about thread safety.
ps. instead of positions you can also have a queue of runnables.
//edit
hmm whatever you pass on to the queue should probably either be immutable or copied, hmm need sleep.
i downloaded the jar you gave but how do i run the program and read the code? Im sorry i have never used a jar before…
also i think there has been some miscommunication because as i was thinking about it the postman and me example isnt really what im talking about. Everything im talking about is client side. Basically i want animations to continue while the client is waiting for info to come in. Basically i want my animations thread to check, somewhere in the loop, to see if there is a new message and if not continue doing whatever it was doing.
so to give an example say im using an instant messanger. Im doing laundry but as soon as my friend sends me a message i leave and go see a movie or whatever. i am the thread and while doing laundry i periodically check to see if there is a new message, if not i continue what i was doing, if so i alter what i was doing. The problem i run into in my program is that i cannot wait for a message while doing laundry. I have to wait for a message to come in and then i can continue the laundry.
^^^ stupid example i know
hmmm after more consideration maybe you do know what im talking about… so is the eventQueue like a mailbox? when one thread reads in data it writes something to the queue and the animation loop checks the queue for new info periodically? and then if new data is recieved it acts accordingly and removes the data?
if you could somehow make eventQueue analogous to real life it might help…
Bingo.
I need to stick the source in a jar here because zip can’t be attached to messages. Since a jar is basicly a zip, you can just unzip the jar. (renaming it works)
[quote]if you could somehow make eventQueue analogous to real life it might help…
[/quote]
Network Thread is your friend.
You are the gameloop.
EventQueue are your mobile phones.
I think you already nailed it earlier.
so just to clarify on the client side i have two threads…
the animation one looks like this?
public void run()
{
animation stuff....
check to see if new message....
according to message status act accordingly
}
and then the second thread would look like this?
public void run()
{
in.readLine();
write to eventQueue
}
that should work right because although the second thread will wait for data over the socket the first thread will continue to run uninteruppted?
Yes