Comments

While not the most graceful approach, there's nothing that is incompatible with what you have available in Duet. If you place this inside a Duet module verbatim and call run() though you're not going to have a good time. That while loop will only break based on reading "bye" from System.in. I'm not actually sure what the default System.in stream is in Duet, but you'd either need to change that loop or redirect something else to System.in.

As this is all in a run() method too I'll assume that you've copied and pasted from some example code where this is part of a Runnable / Thread object. Whatever implementation you choose, just remember to make sure this server is in a thread otherwise Duet will hit that server.accept() call and block until anything connects (as well as blocking later as you read).