automatically exit receiving and transmiting thread when connection is broken
client script