Computer scienceBackendNode.jsCore ConceptsInternal modulesOther modules

Introduction to net module

TCP Server Error Handling

Report a typo

Suppose you have a Node.js TCP server application that attempts to start a server on port 3000 using the code snippet below:

try {
  server.listen(3000, () => {
    console.log(`Server is listening on port 3000`);
  });
} catch (error) {
  if (error.code === 'ERR_SERVER_ALREADY_LISTEN') {
    console.error('Server is already listening on the specified port');
  } else {
    console.error('An error occurred while starting the server:', error);
  }
}

If another process is already listening on port 3000, what message will be logged by the server application?

Select one option from the list
___

Create a free account to access the full topic