Optimze using timeout and socket event source.