Establishing a socket connection

The first thing we'll want to do is set up a simple listening server to which we can connect our socket driver program. To do this, we'll spin up a simple, WebAPI project and run it. Start by opening up Command Prompt and navigating to the directory where you want to create your sample API. Next, create a new WebAPI with the following command from the .NET Core CLI:

dotnet new webapi -n SampleApp

This will spin up a new application from scratch that will be ready-made to receive and respond to HTTP and HTTPS requests made to your local machine and a pre-configured port.

For the purposes of this demonstration, we'll actually want to disable some default functionality in this application. The template for a ...

Get Hands-On Network Programming with C# and .NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.