Java Reference
In-Depth Information
return false;
}
}
// Get a DataInputStream wrapper so we can use
// its readLine() method.
fNetInputReader = new BufferedReader (new
InputStreamReader (fNetInputStream));
// Do a simple log-in protocol. Send a request for the
// users name. Note that a password check could
// be added here.
try {
writeNetOutputLine ("Username: ");
}
catch (IOException e) {
fDataServer.println (
"Connection fails during login");
return false;
}
// Read the user name.
fUser = readNetInputLine ();
if (fUser == null) {
fDataServer.println (
"Connection fails during login");
return false;
}
// Send a message that the login is OK.
try {
writeNetOutputLine ("Login successful");
fDataServer.println (
"Login successful for"+fUser);
}
catch (IOException e) {
fDataServer.println (
"Connection fails during login for " + fUser
);
return false;
}
fDataServer.println (fUser + " connected! " );
fDataServer.println (fSocket.toString ());
// The log-in is successful so now add this DataWorker
// to the DataServer's list of workers.
 
Search WWH ::




Custom Search