first commit

This commit is contained in:
Jose Caban
2025-06-07 01:59:34 -04:00
commit 388ac241f0
3558 changed files with 9116289 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
import java.io.*;
import java.net.*;
class ServerExample extends Thread {
Socket socket;
public static final int PORT = 1234;
public ServerExample(Socket socket) {
this.socket = socket;
}
public void run() {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintWriter pr = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
AbstractNetworkMessage anm;
while((anm = ((AbstractNetworkMessage)(ois.readObject()))) != null) {
String s = anm.tokenize();
System.out.println("Received " + s);
pr.println("Thank you for your input");
pr.flush();
}
} catch (IOException ioe) {
System.out.println("Got IO Exception: " + ioe.getMessage());
} catch(Exception e) {
System.out.println("Something aint workin': " + e.getMessage());
}
}
public static void main(String argv[]) {
try {
ServerSocket ss = new ServerSocket(PORT);
while (true) {
Socket s = ss.accept();
new ServerExample(s).start();
}
} catch (IOException ioe) {
System.out.println("Got IO Exception: " + ioe.getMessage());
}
}
}