Implement basic TCP server
This commit is contained in:
parent
e24fce1662
commit
1b2cd7eccc
1 changed files with 13 additions and 3 deletions
|
@ -1,11 +1,21 @@
|
||||||
package com.spookyinternet.cobweb;
|
package com.spookyinternet.cobweb;
|
||||||
|
|
||||||
|
import java.net.*;
|
||||||
|
|
||||||
public class CobwebServer {
|
public class CobwebServer {
|
||||||
public CobwebServer(int port, byte[] host) {
|
private ServerSocket srv;
|
||||||
System.out.println("Hello, constructor!");
|
|
||||||
|
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) {
|
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 a new issue