Skip to content

j0zko/RobotCheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

C Robot Checker (Simple TCP Client)

A lightweight C program that demonstrates core network programming concepts by connecting to a local or remote web server, sending an HTTP GET request, and scanning the response for specific keywords (like "robot").

How it Works

The program follows the standard TCP Client Lifecycle:

  1. Socket Creation: Initializes a socket using AF_INET (IPv4) and SOCK_STREAM (TCP).
  2. Configuration: Sets up the destination IP (e.g., 127.0.0.1) and Port (e.g., 8000).
  3. Connection: Performs a TCP three-way handshake with the server.
  4. Request: Sends a raw HTTP GET request string.
  5. Response: Captures the incoming data stream into a local buffer.
  6. Analysis: Uses strstr() to scan the received HTML/text for the keyword "robot".

Getting Started

Prerequisites

  • A C compiler (like gcc).
  • Python 3 (for running a local test server).

Running the Project

  1. Start a Local Server In one terminal, navigate to the folder containing your files and start a Python web server:

    python3 -m http.server 8000
  2. Compile the C Code In a second terminal, compile the program:

    gcc functions.c -o functions
  3. Execute Run the binary:

    ./functions

Debugging Features

The current version includes a Debug Block that prints the raw HTTP response headers and body. This is useful for verifying exactly what the server is sending before the logic scan occurs.

Learning Points

  • Byte Ordering: Using htons() to ensure the port number is "Network Byte Order" compliant.
  • Null Termination: Manually adding \0 to the end of the recv buffer so C string functions don't read into "garbage" memory.
  • Blocking Calls: Understanding how recv() pauses program execution until data arrives from the server.

Created as part of a deep dive into C Master networking logic.

About

A simple C program that checks if the site has a robot.txt file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages