The correct syntax uses transport: Transport.TCP and an options object with port.
Step 2: Identify incorrect options
The other options use wrong properties like protocol instead of transport, pass port directly without an options object, use string 'tcp' instead of the Transport.TCP enum, or use the wrong transport type like Transport.HTTP.
The port value is given as a string '3000', but it must be a number.
Step 2: Validate other parts
Host is optional, Transport.TCP is valid, and app.listen() can be awaited without callback.
Final Answer:
Port should be a number, not a string. -> Option A
Quick Check:
Port must be numeric type [OK]
Hint: Port option must be a number, not quoted string [OK]
Common Mistakes:
Passing port as string instead of number
Thinking host is mandatory
Expecting app.listen to require callback
5. You want to create a NestJS TCP microservice that listens on all network interfaces on port 5000 and logs a message when a client connects. Which code snippet correctly implements this?
To listen on all interfaces, host must be '0.0.0.0' and port 5000 is correct.
Step 2: Attach client connection event properly
TCP microservice emits 'connection' event; attaching listener after await app.listen() is correct.
Step 3: Evaluate distractors
Distractors either use the wrong host like 'localhost', omit the host, fail to await app.listen(), or attach the logger to the listen() callback instead of the 'connection' event.