Browse Source

„src/xyz/nextn/WorkerRunnable.java“ hinzufügen

master
Tobias Link 2 years ago
parent
commit
0f8e07f95c
1 changed files with 35 additions and 0 deletions
  1. +35
    -0
      src/xyz/nextn/WorkerRunnable.java

+ 35
- 0
src/xyz/nextn/WorkerRunnable.java View File

@@ -0,0 +1,35 @@
package xyz.nextn;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class WorkerRunnable implements Runnable{

protected Socket clientSocket = null;
protected String serverText = null;

public WorkerRunnable(Socket clientSocket, String serverText) {
this.clientSocket = clientSocket;
this.serverText = serverText;
}

public void run() {
try {
InputStream input = clientSocket.getInputStream();
OutputStream output = clientSocket.getOutputStream();
long time = System.currentTimeMillis();
output.write(("HTTP/1.1 200 OK\n\nWorkerRunnable: " +
this.serverText + " - " +
time +
"").getBytes());
output.close();
input.close();
System.out.println("Request processed: " + time);
} catch (IOException e) {
//report exception somewhere.
e.printStackTrace();
}
}
}

Loading…
Cancel
Save