I created a little tcp server. In the below method, you can see that every time I read input on the buffer reader, I close the client socket connection, the print writer and bufer reader and then during the next iteration of the outer while loop, I reopen new connections. Is this fine or is there a more perfomant way? It works as is, I'm just wondering if I should wait to the entire program shuts down (which could be a long time) before closing these connections.

Java Code:
public void startService(){
		try (
				ServerSocket tcpSocket = new ServerSocket(tcpPort);
		) {			
			while(listening){
				Socket clientSocket = tcpSocket.accept();
				Logger.writeInfo("TCP connection received from " + clientSocket.getInetAddress());
				
				String clientMsg;
				PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
				BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
				
				 if ( (clientMsg = in.readLine()).length() > 0 ) {
					 Logger.writeInfo("client> " + clientMsg);
					 String[] msg = clientMsg.split(" ");
					 String resp="";
					 
					 if(msg[0].equals("invoke")){		
						try {
							// do some stuff that can raise exceptions
							resp = ack;
						} catch(RecordNotFound e){
							resp = e.toString();
						} catch(ReferenceNotUpdated e){
							resp = e.toString();
						} catch(UnitNoResponse e){
							resp = e.toString();
						} catch(CommandNotFound e){
							resp = e.toString();
						} catch(InterruptedException e){
							resp = e.toString();
						}				 
					 } else {
						 resp = "Command not understood.";
					 }
					 out.println(resp);

				 }

				clientSocket.close();
				out.close();
				in.close();

			}			
		} catch (IOException e) {
			Logger.writeError("TCP Connection error:");
			Logger.writeError(e.toString());
			System.exit(1);
		}
	}