Java Reference
In-Depth Information
public
public String toString () {
return
return "ChatHandler[" + login + "]" ;
}
}
}
This code can be used with any reasonable number of clients connected concurrently.
See Also
A good general reference on this chapter's topic is Java Network Programming (O'Reilly).
The server side of any network mechanism is extremely sensitive to security issues. It is easy
for one misconfigured or poorly written server program to compromise the security of an en-
tire network! Of the many books on network security, two stand out: Firewalls and Internet
Security by William R. Cheswick, Steven M. Bellovin, and Aviel D. Rubin (Addison-Wes-
ley) and a series of books with Hacking Exposed in the title, the first in the series by Stuart
McClure, Joel Scambray, and George Kurtz (McGraw-Hill).
This completes my discussion of server-side Java using sockets. A chat server could be im-
plemented using several other technologies, such as RMI (Remote Methods Invocation), an
HTTP web service, JMS (Java Message Service), and a Java Enterprise API that handles
store-and-forward message processing. This is beyond the scope of this topic, but there's an
example of a JMS chat server in Java Message Service by Mark Richards, Richard Monson-
Haefel, and David Chappell.
[ 49 ] You may not be able to pick just any port number for your own service, of course. Certain well-
known port numbers are reserved for specific services and listed in your services file, such as 22 for
Secure Shell, 25 for SMTP, and hundreds more. Also, on server-based operating systems, ports below
1024 are considered “privileged” ports and require root or administrator privilege to create. This was an
early security mechanism; today, with zillions of single-user desktops connected to the Internet, it
provides little real security, but the restriction remains.
[ 50 ] There are some limits to how many threads you can have, which affect only very large, enterprise-
scale servers. You can't expect to have thousands of threads running in the standard Java runtime. For
large, high-performance servers, you may wish to resort to native code (see Calling Other Languages
via Native Code ) using select() or poll() .
[ 51 ] Digital Equipment was absorbed by Compaq, which was then absorbed by HP, but the name re-
mains de because the engineers who name such things don't care for corporate mergers anyway.
 
 
 
Search WWH ::




Custom Search