fixed 100% cpu usage bug in server and monitor modes
added cast (long) to avoid compiling error on sparc architecture