Java Reference
In-Depth Information
} // run
public boolean serviceSetup () {
fDataServer.println ("Client setup...");
// First get the in/out streams from the socket to the
// client
try {
fNetInputStream = fSocket.getInputStream ();
fNetOutputStream = fSocket.getOutputStream ();
}
catch (IOException e) {
fDataServer.println (
"Unable to get input/output streams");
return false;
}
// Create a PrintWriter class for sending text to the
// client. The writeNetOutputLine method will use this
// class.
try {
fPrintWriter = new PrintWriter (
new OutputStreamWriter (fNetOutputStream,
" 8859 - 1 " ), true);
}
catch (Exception e) {
fDataServer.println (
"Fails to open PrintWriter to client!");
return false;
}
// Check if the server has room for this client.
// If not, then send a message to this client to
// tell it the bad news.
if (!fDataServer.clientPermit ()) {
try {
String msg =
"Sorry, we've reached the maximum number of
clients";
writeNetOutputLine (msg);
fDataServer.println (msg);
return false;
}
catch (IOException e) {
fDataServer.println (
" Connection fails during login " );
 
Search WWH ::




Custom Search