I am writing a program which has a possibility to accept tcp connections. It is more less doing what I am expecting it to do however when it detects that client disconnects