Close function and some try-catch

Add Close function for clients sockets and try-catch block in functions
Accept and Receive