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.
git clone https://github.com/ECNU-ICALK/AutoSkill
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"
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/c-windows-winsock-multi-threaded-url-visitor/SKILL.mdC++ 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
- Library Usage: Use Winsock2 (
,<winsock2.h>
). Do NOT use Boost or other third-party libraries.<ws2tcpip.h> - Initialization: Initialize Winsock using
at the start and clean up withWSAStartup
at the end.WSACleanup - User Input: The program must prompt the user via the console for:
- The target URL (hostname).
- The total number of visits to perform.
- DNS Resolution: Use
to resolve the hostname string to an IP address before connecting.getaddrinfo - Concurrency: Implement a batching mechanism for threads (e.g., process 10 connections simultaneously). Use
to manage the thread pool.std::vector<std::thread> - 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.
- Batch Processing: Loop until the total number of visits is reached, launching batches of threads and waiting for them to join (
) before launching the next batch.t.join()
Anti-Patterns
- Do not hardcode IP addresses; always resolve from the user-provided URL.
- Do not use
if it causes ambiguity; use ternary operators if necessary.std::min - Do not use Boost libraries.
Interaction Workflow
- Initialize Winsock.
- Prompt for URL and total visits.
- Call a processing function (e.g.,
) that manages the thread batches.ProcessVisits - Inside the thread function, resolve DNS, connect, wait, and disconnect.
- Cleanup Winsock upon completion.
Triggers
- C++ winsock multithreaded connection
- Windows socket visitor
- C++ load testing tool
- Winsock concurrent connections
- C++ URL connection batcher