MAIN

Host,port

Default selector

Start Socket

BIND(); LISTEN()

Accept Wrapper

Service Connection

Unblock Socket

Selector registers the socket

Select events ready for I/O

Events [KEY, MASK]

FOR KEY, MASK , IF KEY.DATA IS EMPTY

(NO) Serve the client

SERVICE_CONNECTION(KEY, MASK)

(YES) accept new connection

ACCEPT_WRAPPER(KEY.FILEOBJ)

while !keyboard interrupt