This is a basic TCP server implemented in C# that handles basic HTTP requests for specific routes.
This code implements a simple TCP server that accepts client connections and processes basic HTTP requests for different routes. It contains the following functionalities:
-
Receives HTTP GET requests from clients.
-
Parses the request route and responds with specific data for known routes.
-
Supports a specific route, "/resposta1," returning specific content defined in the code.
- .NET Core SDK installed on your machine.
- Clone the repository:
git clone https://github.com/C4mps41205/ApiWithSocket/)https://github.com/C4mps41205/ApiWithSocket/- Open a web browser or use tools like cURL or Postman.
- Access the server using the configured IP and port (for example,
http://192.168.0.22:666). - Try different routes, including
/resposta1, to see the server's responses.
You can use cURL, a command-line tool for transferring data with URL syntax, to interact with the server.
-
To perform a GET request for the
/resposta1route:curl http://192.168.0.22:666/resposta1
This will output the response from the server for the /resposta1 route.
Postman is a popular API development environment that allows you to create and test APIs.
- Open Postman and create a new request.
- Set the request type to GET.
- Enter the server's URL in the address bar (for example,
http://192.168.0.22:666/resposta1). - Send the request to see the server's response.
Experimenting with different routes and tools will showcase the server's ability to handle various requests and responses.
- Ensure to adjust the server's IP address to the correct one on your local network.
- This is a basic example and can be expanded to handle more routes, HTTP methods, and more complex logic.


