瀏覽代碼

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

master
Tobias Link 5 年之前
父節點
當前提交
0f8e07f95c
共有 1 個文件被更改,包括 35 次插入0 次删除
  1. +35
    -0
      src/xyz/nextn/WorkerRunnable.java

+ 35
- 0
src/xyz/nextn/WorkerRunnable.java 查看文件

@@ -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…
取消
儲存