I am trying to set up an http server using java. I am currently using the Vert.x package. This is my first experience with http server so i am kind of lost and don't really know how to proceed, hence i am seeking guidance. I have scrambled a a piece of code (probably not full) from some examples that i found on the subject.
public class SimpleFileServer extends AbstractVerticle {
private HttpServer httpServer = null;
@Override
public void start() throws Exception {
httpServer = vertx.createHttpServer();
httpServer.requestHandler(new Handler<HttpServerRequest>() {
@Override
public void handle(HttpServerRequest request) {
System.out.println("incoming request!");
Buffer fullRequestBody = Buffer.buffer();
if(request.method() == HttpMethod.POST){
request.handler(new Handler<Buffer>() {
@Override
public void handle(Buffer buffer) {
fullRequestBody.appendBuffer(buffer);
}
}
}
}
});
httpServer.listen(3030);
}}
i have many question on this matter, for example: what should be added to the code in order to send files (once every specific time interval) to the server? how can i check whether the server is working properly? assuming i don't have another computer to connect to it as a client? Should i try to set up TCP server instead?
I am basically seeking for any guidance on this matter, very basic stuff. any pointers, suggestions and good examples would be highly appreciated. thank you.