Implement basic TCP server
This commit is contained in:
parent
e24fce1662
commit
1b2cd7eccc
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue