refectory the code: 1. extract readFromSocket and writeToSocket. 2. merge GetThread and GetThread2