with rewrite and socket