recovering Server.java from backup

This commit is contained in:
Dan Ballard 2011-05-20 11:09:03 -07:00
parent a0200c208c
commit 93bc6d8e09
1 changed files with 63 additions and 0 deletions

63
Server.java Normal file
View File

@ -0,0 +1,63 @@
import java.applet.*;
//import java.awt.*;
import java.awt.event.*;
import javax.swing.Timer;
import java.awt.image.*;
import java.lang.*;
import java.io.*;
import java.net.*;
class Server implements Runnable {
private ServerSocket server;
private ResManager res;
private Applet applet;
public Server(ResManager r, String codeBase, Applet a) {
applet = a;
res = r;
res.putNodeData("originURL", codeBase);
res.reloadSite();
//res.alert("Loaded site");
boolean bound = false;
while(!bound)
{
try {
server = new ServerSocket(res.PORT);
bound = true;
} catch (IOException e) {
res.PORT++;
}
}
applet.repaint();
res.openDebugLog("me");
}
public void run() {
try {
//res.alert("running server");
while (!res.killSwitch) {
Socket sock = server.accept();
//res.alert("ACCEPTED!");
new Thread(new ConnHandler(sock, res)).start();
//handler.run();
//res.alert("RESTARTING LOOP");
}
server.close();
} catch (IOException e) {
System.out.println("IOException in init(): " + e.toString());
res.error( "IOException in init(): " + e.toString());
}
applet.repaint();
}
}