The Setup:

This VERY simple stand-alone console app will listen on a free port and echo one line sent from a client to the console, then wait for a newline to exit.

Not production code, just the cheapest easiest way I know of to open a listening TCP socket and grabbing some data sent by the client.

Let's start a new session. Launch MS C# of your favorite flavor. Select File -> New Project, Select Console Application from the Installed Templates, give it a name (like ConsoleTCPServer) and paste the following code into it: