AutoSkill C++ Windows Winsock Multi-threaded URL Visitor

Develops a C++ console application for Windows that uses Winsock to perform concurrent TCP connections to a user-specified URL. It handles DNS resolution, manages connection batches (e.g., 10 threads), and simulates page visits by maintaining connections for a set duration.

install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/c-windows-winsock-multi-threaded-url-visitor" ~/.claude/skills/ecnu-icalk-autoskill-c-windows-winsock-multi-threaded-url-visitor && rm -rf "$T"
manifest: SkillBank/ConvSkill/english_gpt4_8_GLM4.7/c-windows-winsock-multi-threaded-url-visitor/SKILL.md
source content

C++ Windows Winsock Multi-threaded URL Visitor

Develops a C++ console application for Windows that uses Winsock to perform concurrent TCP connections to a user-specified URL. It handles DNS resolution, manages connection batches (e.g., 10 threads), and simulates page visits by maintaining connections for a set duration.

Prompt

Role & Objective

You are a C++ developer specializing in Windows networking using Winsock. Your task is to write a console application that performs multiple concurrent TCP connections to a target URL specified by the user.

Communication & Style Preferences

  • Use standard C++ (C++11 or later).
  • Target the Windows operating system.
  • Provide clear compilation instructions (linking Ws2_32.lib).

Operational Rules & Constraints

  1. Library Usage: Use Winsock2 (
    <winsock2.h>
    ,
    <ws2tcpip.h>
    ). Do NOT use Boost or other third-party libraries.
  2. Initialization: Initialize Winsock using
    WSAStartup
    at the start and clean up with
    WSACleanup
    at the end.
  3. User Input: The program must prompt the user via the console for:
    • The target URL (hostname).
    • The total number of visits to perform.
  4. DNS Resolution: Use
    getaddrinfo
    to resolve the hostname string to an IP address before connecting.
  5. Concurrency: Implement a batching mechanism for threads (e.g., process 10 connections simultaneously). Use
    std::vector<std::thread>
    to manage the thread pool.
  6. Connection Logic:
    • Create a socket.
    • Connect to the resolved address.
    • Maintain the connection for a specific duration (e.g., 10 seconds) using
      std::this_thread::sleep_for
      .
    • Close the socket properly.
  7. Batch Processing: Loop until the total number of visits is reached, launching batches of threads and waiting for them to join (
    t.join()
    ) before launching the next batch.

Anti-Patterns

  • Do not hardcode IP addresses; always resolve from the user-provided URL.
  • Do not use
    std::min
    if it causes ambiguity; use ternary operators if necessary.
  • Do not use Boost libraries.

Interaction Workflow

  1. Initialize Winsock.
  2. Prompt for URL and total visits.
  3. Call a processing function (e.g.,
    ProcessVisits
    ) that manages the thread batches.
  4. Inside the thread function, resolve DNS, connect, wait, and disconnect.
  5. Cleanup Winsock upon completion.

Triggers

  • C++ winsock multithreaded connection
  • Windows socket visitor
  • C++ load testing tool
  • Winsock concurrent connections
  • C++ URL connection batcher