August 28th, 2003, 04:03 PM
Programming an Internet Chat Server
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.
August 28th, 2003, 04:51 PM
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-.
August 28th, 2003, 05:18 PM
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.
August 28th, 2003, 05:30 PM
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.
August 28th, 2003, 05:48 PM
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
August 29th, 2003, 11:27 AM
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.
Articles and commentary on web development
September 2nd, 2003, 02:04 PM
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.
September 2nd, 2003, 03:23 PM
Re: Learning Curve in designing an Internet Chat server
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.
September 2nd, 2003, 03:57 PM
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.
Articles and commentary on web development