while(true) { auto client = socket.accept(); spawn(&handleConnection, cast(shared)client); } void handleConnection(shared Socket sclient) { Socket client=cast()sclient; //do stuff like receive and send }