Java Reference
In-Depth Information
"<
html
><
head
>\
n
<
TITLE
>
Solar Panel Voltage - ADC
Readout
<
/TITLE
>
\
n
<
/HEAD
>"
;
String fWebPageBot ="</body>\n </html>";
/** Pass the socket as a argument to the constructor **/
Worker (Socket client) throws SocketException {
fClient = client;
// Set the thread priority down so that the
// ServerSocket will be responsive to new clients.
setPriority (NORM
-
PRIORITY - 1);
}
// ctor
/**
* This thread receives a request from the client for a
*aweb page file. The file name is found relative to
* the directory of this code.
**/
public void run ()
{
boolean read
-
adc
=
false;
try
{
BufferedReader client
-
in
=
new BufferedReader (
new InputStreamReader(fClient.getInputStream()));
// Now get an output stream to the client.
OutputStream client
-
out =
fClient.getOutputStream ();
// Use PrintStream for SNAP output
PrintStream pw
-
client
-
out =
new PrintStream (client
-
out);
// First read the message from the client
String client
-
str
=
client
-
in.readLine ();
System.out.println (
"
Client message:
"
+client
-
str);
// Split the message into substrings.
String [] tokens = split (client
-
str);
// Check that the message has a minimun number of
// words and that the first word is the GET command.
if ((tokens.length >= 2) &&
tokens[0].equals ("GET")) {
String file
-
name = tokens[1];
Search WWH ::
Custom Search