#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Location
    Tallahassee
    Posts
    55
    Rep Power
    14

    Programming an Internet Chat Server


    Hi all,
    I am looking to build an Internet chat server to acommodate some of the requirements specs of recent projects. The bad news is that I am very new to the TCP/IP networking world. I need a general opinion of what I should do? First of all, what language should I implement this with. My options are C, PERL, PHP, and JAVA(combinations are also accepted.)
    Please let me know where if there any good introductory books out there onh devloping web servers and things that I might need to know before I start designing the web server.
    Also, please tell me why you choose the programming language that you did and what the advantages are over the other ones. Thank you.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    europe
    Posts
    274
    Rep Power
    0
    why do u try to write ur own internet chat server, since there r many internet chat server alreay free to download ...
    search at google for " internet chat server "
    you'll find the answer-.

    -stagy
  4. #3
  5. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,158
    Rep Power
    2222
    stage_watchman makes a very valid point. It's normally advisable to avoid re-inventing the wheel, especially if there's a deadline and you're just starting to learn how to do it.

    However, it could also be the case that you want to use this excuse ... I mean, opportunity ... to learn network programming.

    I've started putting a set of sockets programming pages up on the Web at http://members.aol.com/dsc30574/sockets/index.html . It's starting out more of an orientation for programmers who are just starting out with sockets. At the very least, I'm trying to give people an idea of what's involved and to provide them with links to get started. In that case, you should make sure to look at my resources page at http://members.aol.com/dsc30574/sockets/resources.html .

    My language of choice in this is C, because I can do whatever I need to. Also, the sockets API was originally written for C. If you're just getting started with sockets programming, I would recommend Donahoo and Calvert's book, "The Pocket Guide to TCP/IP Sockets: C Version " (AKA "TCP/IP Sockets in C: Practical Guide for Programmers"). It's short, inexpensive ($15), and gets you started programming almost immediately. Its orientation is C on UNIX, but their site also provides instructions for working with Winsock.

    Which raises an important question: which OS will you be using? If Windows, then you will be using Winsock. Fortunately, Winsock supports most of the BSD sockets API, so the differences are not that great. Though working in Windows instead of in UNIX/Linux would restrict some of your design options relative to forking child processes and working with threads (supported in both, but done differently). In future questions that arise, you should mention your OS as well.

    perl has some nice sockets support also, plus a number of modules have been written to support different protocols, such as HTTP, FTP, telnet. In that case, I would recommend Lincoln Stein's book, "Network Programming with Perl". In it, he also reviews a number of different server designs, including a chat server.

    Java also supports sockets, though I'm not very familiar. It encapsulates a lot of it in special classes which keep you at a high level of abstraction and well away from the actual sockets code. Donahoo and Calvert also have a Java book, "TCP/IP Sockets in Java: Practical Guide for Programmers", but I have only used it to look up a few things so far.

    I'm not familiar with php.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Location
    BCN
    Posts
    84
    Rep Power
    13
    Hi,

    Google for "beej's networking tutorial" or something like these. It's a very good introduction to network programming with C.
    Since it's a long run server and minor memory leaks or errors can become, eventually, important I would propose C or Java. And, if C use C++, you may want to encapsulate your connections as an object; I've recently done something similar and having a clear interface for connections helped a lot.
  8. #5
  9. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,625
    Rep Power
    4247
    I wrote one a while back -- I used C for the server and java for the client end. See this link for more. I have tested the server code with Linux and FreeBSD. With a few minor changes, the server code actually works for OpenBSD and NetBSD as well. I'll upload the new code one of these days, but this should get you started at least :).
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Location
    Flint, MI
    Posts
    328
    Rep Power
    12
    Supaben,

    C is definitely the language of choice here for a simple internet chat server. Of course, this being the C forum, we might be biased.

    I've done this a couple of times, and I'll say that you've got a minor learning curve in front on you. Network programming is an interesting ballgame. It's fun, and I'm glad that I have at least a little experience, but it's different. You're going to get very good at low level i/o.

    If you want something pre-written just to help people communicate, Thomas Boutell's Perl Mud program is very easy to install and use.
    Clay Dowling
    Lazarus Notes
    Articles and commentary on web development
    http://www.lazarusid.com/notes/
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Location
    Tallahassee
    Posts
    55
    Rep Power
    14

    Learning Curve in designing an Internet Chat server


    you maybe right dwise1_aol this is really just a chance to break into the network programming arena. I have another question for you guys. What kind of learning curve should I expect? Assume that I am an average C programmer and I am a absolutely new in the network programming field.
  14. #8
  15. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,158
    Rep Power
    2222

    Re: Learning Curve in designing an Internet Chat server


    Originally posted by supaben34
    you maybe right dwise1_aol this is really just a chance to break into the network programming arena. I have another question for you guys. What kind of learning curve should I expect? Assume that I am an average C programmer and I am a absolutely new in the network programming field.
    Not horribly steep, but you are going to stub your toes a lot on little mistakes like not converting byte order. The server will need to use either multiple processes (forking, if on Linux, otherwise forget it), multithreading (available on Linux and Windows), or multiplexing (with select() -- also available on both), so if you're not very comfortable working with whichever on you pick, then that will add to the learning curve and debugging headaches. Plus any number of stupid mistakes and oversights (that we have all made ourselves).

    Sounds like fun. Let us know how it turns out.

    Did I mention Lincoln Stein's book? Even though it deals with Perl, its discussion of server design is excellent and it does use a chat server as an extended example.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Location
    Flint, MI
    Posts
    328
    Rep Power
    12
    I'm not sure about Linux, but on a BSD based system, multi-processing programming isn't even necessary. The select() function can make a single-threaded server that can handle a very large number of users without lag.

    Without that you'll need to find some other way to exchange data between the control threads. Shared memory isn't bad, but synchronizing it will take a little work.
    Clay Dowling
    Lazarus Notes
    Articles and commentary on web development
    http://www.lazarusid.com/notes/

IMN logo majestic logo threadwatch logo seochat tools logo