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.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of C Windows Winsock Multi Threaded Url Visitor?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ecnu-icalk-c-windows-winsock-multi-threaded-url-visitor)
---
id: "857f3b77-818c-4a80-a9d3-8e552d59d1c3"
name: "C++ Windows Winsock Multi-threaded URL Visitor"
description: "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."
version: "0.1.0"
tags:
- "C++"
- "Winsock"
- "Windows"
- "Networking"
- "Multithreading"
triggers:
- "C++ winsock multithreaded connection"
- "Windows socket visitor"
- "C++ load testing tool"
- "Winsock concurrent connections"
- "C++ URL connection batcher"
---
# 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