Skip to content

Instantly share code, notes, and snippets.

View JamieAP's full-sized avatar
🎯
Focusing

Jamie JamieAP

🎯
Focusing
View GitHub Profile
try {
ServerBootstrap b = new ServerBootstrap();
b.group(acceptorGroup, handlerGroup)
.channel(NioServerSocketChannel.class)
.childHandler(new MySocketInitialiser())
.option(ChannelOption.SO_BACKLOG, 5)
.childOption(ChannelOption.SO_KEEPALIVE, true);
b.localAddress(port).bind().sync();
LOG.info("Started on port {}", port);
NioEventLoopGroup acceptorGroup = new NioEventLoopGroup(2); // 2 threads
NioEventLoopGroup handlerGroup = new NioEventLoopGroup(10); // 10 threads
NioEventLoopGroup acceptorGroup = new NioEventLoopGroup(2); // 2 threads
NioEventLoopGroup handlerGroup = new NioEventLoopGroup(10); // 10 threads
@JamieAP
JamieAP / HelloWorld.java
Created December 26, 2015 17:31
Spark Example
import static spark.Spark.*;
public class HelloWorld {
public static void main(String[] args) {
get("/hello", (req, res) -> "Hello World");
}
}
@JamieAP
JamieAP / express-example.js
Last active December 26, 2015 17:29
Express Example
app.get('/', function (req, res) {
res.send('Hello World!');
});