Implement basic TCP server

This commit is contained in:
Nick Chambers 2024-04-14 08:19:02 -05:00
parent e24fce1662
commit 1b2cd7eccc
1 changed files with 13 additions and 3 deletions

View File

@ -1,11 +1,21 @@
package com.spookyinternet.cobweb;
import java.net.*;
public class CobwebServer {
public CobwebServer(int port, byte[] host) {
System.out.println("Hello, constructor!");
private ServerSocket srv;
public CobwebServer(int port, byte[] host) throws Exception {
this.srv = new ServerSocket(port, 64, InetAddress.getByAddress(host));
}
public void on(String get, String path, HttpRequestFunction fn) {
System.out.println("Hello, on!");
}
public void run() throws Exception {
while(true) {
Socket cli = this.srv.accept();
new HttpThread(cli).start();
}
}
}