Event Dispatch and Handling
Feb 2, 2021
Essentially the same as ServerSocket, expect that it is called non-blocking IO function; what this means is when a request comes in, we will immediately handle it, but we can also check for a request and not do anything, if there is none waiting
var sock = ServerSocketChannel.open();
sock.socket().bind(new InetSockerAddress(8000));
sock.configureBlocking(false);
Handler A handles the socket request and then it calls the OS or the Java JDK with something called a non-blocking read; it registers that we should read something and registers a callback handler.
When we get a new request, what should we do?
- add an element to the queue specifying what to do with the socket
- passing the socket in as some kind of state