Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Building a Java chat server
#1

Building a Java chat server

[attachment=351]

Should I take this tutorial?

In this tutorial, we will build both the server and client sides of a simple chat system. This
tutorial is for someone with little or no experience doing networking programming. We'll cover
topics such as networking and multithreading in enough detail so that you'll be able to follow
the examples, even if you have little or no experience doing this kind of programming. You
will, however, need to be familiar with basic object-oriented programming in the Java
language.

Navigation

Navigating through the tutorial is easy:
* Select Next and Previous to move forward and backward through the tutorial.
* When you're finished with a section, select the next section. You can also use the Main
and Section Menus to navigate the tutorial.
* If you'd like to tell us what you think, or if you have a question for the author about the
content of the tutorial, use the Feedback button.

Introduction

What you'll learn
In this tutorial, you'll build a simple, centralized, connection-oriented Java server. In doing
so, you'll learn a basic framework that you can use when creating such a server, using
time-honored techniques that work well in many situations. We'll also examine some of the
limitations of this framework and explore ways of getting around them.

What is a connection-oriented server?

Generally speaking, the job of any server is to provide a centralized service. However, there
are many different ways of providing services, and many different ways to structure the
communications.
Chat is roughly described as a connection-oriented service, because a user establishes a
connection and maintains that connection, sending and receiving text for the duration of the
session.
This is in contrast to the Web, where the protocol is (at least in theory) transactional -- the
browser asks for a page, and the server sends it; the connection is then closed. (In practice,
the connection is kept open and reused, but this is more a speed-optimization than a
structuring metaphor.)
We'll be creating a stripped-down, connection-oriented server. Learning the basic
framework will help you a great deal in creating other connection-oriented servers in the
future.

Why create from scratch?

In creating this prototype server, we'll be using nothing more than the basic packages built
into every Java implementation. This allows us to explore server programming at the very
lowest level possible in the Java language.
There are certainly many systems available that can take care of many of these networking
details for you. In many cases, the best real-world solution is to use an existing framework,
because it often provides useful features such as fault-tolerance, load-balancing, and
sessioning.
It is, nevertheless, crucial to understand how these things work at the lowest level. No
existing solution is perfect for all problems, and existing solutions often have minor flaws that
your code must work around. Simply choosing the right pre-packaged solution takes a
discriminating eye that has been educated as to the tradeoffs inherent in various techniques.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2024 iAndrew & Melroy van den Berg.