The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Programming on the internet?

curbycurby Registered User regular
edited September 2007 in Help / Advice Forum
I know there are a lot of people here that are into programming and I was wondering if anyone can point me in the right direction in terms of what I need to do to make programs such as multiplayer board games that I can put up on the web. What do I need to do/read to get started on this? The project that I am working on needs to be fairly fast (is there a way to do this in C/C++?), capable of being secure (eg. not actionscript) and it needs to be able to run on a web page.

I think my best bet would probably be something like java, since it's not OS-specific, but if there are any ways to work around that, then that's totally cool (maybe something like abstract factory design patterns??).

Anyway, all I need is some advice on how I would actually go about linking 2 applications on the net so that they can communicate with each other from different computers. I'm still googling this like mad, but there doesn't really seem to be that much info on this.

Thanks.

linktous.gif
curby on

Posts

  • ASimPersonASimPerson Cold... ... and hard.Registered User regular
    edited September 2007
    Do you know any programming at all?

    If you need this to be on the web, a Java applet or Flash may be your best bet. But if you don't know how to program, you need to learn the basics first - so start out with some basic tutorials. (As for where to find them, I may not be of much help there - I learned most of my programming in the classroom starting in high school.)

    ASimPerson on
  • DrFrylockDrFrylock Registered User regular
    edited September 2007
    It really depends on what kind of application you want, how you want to deploy it, who you want to be able to run it, and so on. Connecting two computers over the Internet can be as simple as opening a TCP connection (socket) from one computer to the other, which is nearly trivial in programming languages like Java. However, to actually make a workable game on the Internet, you have to take into account about a dozen other factors.

    I'm confused by your post because of how you phrase the questions. Developing something in C/C++ doesn't necessarily make it fast, nor does developing something in Java make it slow (these days, Java runs about as fast as C/C++, although it takes up more memory). Developing something in Actionscript doesn't necessarily make it insecure. I'm not sure how you think "abstract factory design patterns" (a real concept, but really a simple programming solution to a common issue in object oriented programming) would be something to worry about at all at this point.

    If you want something to run on a web page, you generally need something that will run in a browser. So, you're looking at things like Java applets, Flash, or advanced Javascript (e.g., AJAX).

    In general, these games require some server to be out there on the internet mediating play between the clients, who are playing. The reason you can't generally connect clients directly to one another and have them play is because of security. For example, Java's applet security manager will not let an applet open an outbound connection to a computer other than the Web server that served the applet in the first place. There are exceptions to this: a digitally signed applet can do it, but then Java will throw up a dialog box asking for permission and such. Second, you have to take into account NAT boxes and firewalls. If you're behind a NAT box, you can make outbound connections easily but nobody can (in general) initiate an inbound connection to you. So here, both players would make outbound connections from their applets to the game server, and the server would mediate communication between the two.

    This is all well and good, but you also have to consider firewalls. Depending on how strict an outgoing firewall is, it may permit any outgoing connections, or it may filter outgoing connections. At my work, for example, my firewall will only permit outbound HTTP connections on port 80, and outbound HTTPS connections on port 443. So, if you wanted me to be able to play your game at work, you'd have to set up the server to mediate communications through HTTP or HTTPS.

    If you wanted to do this in Java, and you wanted to take account of both NATs and firewalls, then you'd basically have game applets that are downloaded through a Web page, plus custom Java servlets or JSPs that handled communications coming back from the applets. Each applet would periodically poll the server for new game state updates, and also make outbound requests (over HTTP to your custom servlet/JSP) to update the game state (e.g., post new moves). The basic idea would be similar but the implementations would be different with Flash+actionscript or AJAX. For example, with AJAX, your clients would be in Javascript, and they would be sending and receiving data from the server by sending XML documents back and forth over HTTP.

    I've written many applications of these kinds, but never a networked game. There may be (although I don't know of one) some sort of middleware or set of libraries you can use to make some of this easier.

    None of this is tremendously difficult for an experienced software developer, but the amount of technologies and things to be aware of can be daunting if you've never written a simple TCP application at all, for example.

    DrFrylock on
  • LewishamLewisham Registered User regular
    edited September 2007
    Frylock: I think we can just surmise that the OP has no idea what he/she is doing, thus is not in a position to make said game :) The sheer number of buzzwords and jargon makes me think he/she has Googled for how to do it, without actually understanding any of it.

    Lewisham on
  • curbycurby Registered User regular
    edited September 2007
    Lewisham/ASimPerson: I should have rephrased my question. I've made many programs in several languages and I was wondering about network programming.

    Frylock:

    The thing I was worried about in terms of using Java over C is the fact that it does use more memory, and though it can execute as fast as C/C++, it will still be slower just because it has more things to do. As far as the abstract factory, that's just a random idea to do with how to get around that. Not really something I'm worried about (and it's super easy anyway). Also, thanks for the info. I'll definitely be setting up a server and looking into dealing with firewalls, etc.

    curby on
    linktous.gif
  • TechnicalityTechnicality Registered User regular
    edited September 2007
    DrFrylock wrote: »
    There may be (although I don't know of one) some sort of middleware or set of libraries you can use to make some of this easier.

    For Flash there is Electroserver. I never found anything like that for c++ though.

    I would have thought that online board games are one of the things where speed and security are of low importance.

    Technicality on
    handt.jpg tor.jpg

  • ecchiecchi Registered User regular
    edited September 2007
    Check out Game Gardens. It's by the creators of the MMO Puzzle Pirates (and I think they share code). I haven't used it yet, but as far as I know it's basically a Java game library with an easy-to-use networking API. Sounds perfect for making online board games -- the tutorial is actually a guide to implementing Reversi!

    ecchi on
  • DrFrylockDrFrylock Registered User regular
    edited September 2007
    curby wrote: »
    The thing I was worried about in terms of using Java over C is the fact that it does use more memory, and though it can execute as fast as C/C++, it will still be slower just because it has more things to do. As far as the abstract factory, that's just a random idea to do with how to get around that. Not really something I'm worried about (and it's super easy anyway). Also, thanks for the info. I'll definitely be setting up a server and looking into dealing with firewalls, etc.

    "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." --Attributed to Tony Hoare, paraphrased by Donald Knuth

    You're really making very little sense here; how does Java have "more things to do" and how will using abstract factory design patterns mitigate that? You're saying "I'm thinking of designing my first car; I'm sort of worried about whether the speed the automatic windows roll up should be 2.1 or 2.2 inches per second." That kind of detail is below the level where you need to be thinking here. In your decision between C, C++, Java, and some other technology should not be based on efficiency (or lack thereof) at this point, it should be based on the likelihood that you will ever be able to use that technology to create something resembling a working game. Hint: C++ is not the technology you should use to maximize your chances of success.

    DrFrylock on
Sign In or Register to comment.