Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Deep integration with socket APIs for TCP/UDP programming across platforms. Execute socket operations, analyze socket options and buffer configurations, debug connection states, and generate optimized socket code for different I/O models.
.claude/skills/a5c-ai-socket-programming/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 124% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 280% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 64% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 455% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 211% | 0% |
You are socket-programming - a specialized skill for low-level socket programming, providing deep integration with TCP/UDP socket APIs across platforms (BSD sockets, Winsock).
This skill enables AI-powered socket programming operations including:
netstat or ss CLI tools for socket analysisExecute and analyze socket operations across platforms:
c// TCP Socket Server Pattern (POSIX) int server_fd = socket(AF_INET, SOCK_STREAM, 0); // Socket options int opt = 1; setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); setsockopt(server_fd, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)); // Buffer configuration int send_buf = 65536; int recv_buf = 65536; setsockopt(server_fd, SOL_SOCKET, SO_SNDBUF, &send_buf, sizeof(send_buf)); setsockopt(server_fd, SOL_SOCKET, SO_RCVBUF, &recv_buf, sizeof(recv_buf)); // TCP options int nodelay = 1; setsockopt(server_fd, IPPROTO_TCP, TCP_NODELAY, &nodelay, sizeof(nodelay));
Debug connection states using system tools:
bash# Linux - ss command (preferred) ss -tnp state established '( sport = :8080 )' ss -tnp state time-wait ss -s # Summary statistics # Cross-platform - netstat netstat -an | grep :8080 netstat -an | grep ESTABLISHED netstat -an | grep TIME_WAIT # Socket buffer analysis ss -tnpm # Show memory usage cat /proc/net/sockstat # Socket statistics
Configure non-blocking sockets for high-performance:
c// Set non-blocking mode (POSIX) int flags = fcntl(sockfd, F_GETFL, 0); fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); // Windows equivalent u_long mode = 1; ioctlsocket(sockfd, FIONBIO, &mode);
Interpret and handle socket errors:
c// Common socket errors and handling switch (errno) { case EAGAIN: // Would block (non-blocking) case EWOULDBLOCK: // Same as EAGAIN on most systems // Retry later or wait for event break; case EINTR: // Interrupted by signal // Retry the operation break; case ECONNRESET: // Connection reset by peer // Close and cleanup break; case ETIMEDOUT: // Connection timed out // Reconnect logic break; case EADDRINUSE: // Address already in use // Use SO_REUSEADDR or wait break; }
Generate optimized socket implementations:
c#include <sys/socket.h> #include <netinet/in.h> #include <netinet/tcp.h> #include <arpa/inet.h> #include <unistd.h> #include <fcntl.h> typedef struct { int port; int backlog; int recv_buffer_size; int send_buffer_size; bool tcp_nodelay; bool non_blocking; } server_config_t; int create_tcp_server(server_config_t *config) { int server_fd = socket(AF_INET, SOCK_STREAM, 0); if (server_fd < 0) return -1; // Reuse address int opt = 1; setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); // Buffer sizes if (config->recv_buffer_size > 0) { setsockopt(server_fd, SOL_SOCKET, SO_RCVBUF, &config->recv_buffer_size, sizeof(int)); } if (config->send_buffer_size > 0) { setsockopt(server_fd, SOL_SOCKET, SO_SNDBUF, &config->send_buffer_size, sizeof(int)); } // TCP_NODELAY (disable Nagle's algorithm) if (config->tcp_nodelay) { int nodelay = 1; setsockopt(server_fd, IPPROTO_TCP, TCP_NODELAY, &nodelay, sizeof(nodelay)); } // Non-blocking mode if (config->non_blocking) { int flags = fcntl(server_fd, F_GETFL, 0); fcntl(server_fd, F_SETFL, flags | O_NONBLOCK); } struct sockaddr_in addr = { .sin_family = AF_INET, .sin_addr.s_addr = INADDR_ANY, .sin_port = htons(config->port) }; if (bind(server_fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { close(server_fd); return -1; } if (listen(server_fd, config->backlog) < 0) { close(server_fd); return -1; } return server_fd; }
cint create_udp_socket(int port, bool non_blocking) { int sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd < 0) return -1; // Allow multiple sockets to bind to same port int opt = 1; setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); // Non-blocking mode if (non_blocking) { int flags = fcntl(sockfd, F_GETFL, 0); fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); } struct sockaddr_in addr = { .sin_family = AF_INET, .sin_addr.s_addr = INADDR_ANY, .sin_port = htons(port) }; if (bind(sockfd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { close(sockfd); return -1; } return sockfd; }
Handle cross-platform socket programming:
| Feature | POSIX (Linux/macOS) | Windows (Winsock) | |---------|---------------------|-------------------| | Header | <sys/socket.h> | <winsock2.h> | | Init | Not required | WSAStartup() | | Close | close(fd) | closesocket(sock) | | Error | errno | WSAGetLastError() | | Non-block | fcntl(O_NONBLOCK) | ioctlsocket(FIONBIO) | | Poll | poll() / epoll() | WSAPoll() / IOCP |
This skill can leverage the following MCP servers for enhanced capabilities:
| Server | Description | Integration | |--------|-------------|-------------| | Claude-Flow | Agent orchestration with real-time communication | Real-time socket testing | | Docker MCP Toolkit | Container isolation for socket testing | Safe network experimentation |
This skill integrates with the following processes:
tcp-socket-server.js - TCP server implementationudp-socket-server.js - UDP server implementationevent-driven-socket-handler.js - Event-based socket handlingconnection-pool.js - Connection pool managementWhen executing operations, provide structured output:
json{ "operation": "analyze", "target": "socket", "address": "0.0.0.0:8080", "status": "success", "findings": [ "Socket is in ESTABLISHED state", "Send buffer: 65536 bytes", "Recv buffer: 65536 bytes", "TCP_NODELAY enabled" ], "recommendations": [ "Consider increasing buffer size for high-throughput" ], "artifacts": ["socket_config.c"] }
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 13,444 | 26,551 | +97% | 1 | 1 | 0% | 2,599 | 5,824 | +124% | 0 | 0 | — |
case-02 | pass→pass | 16,234 | 16,301 | +0% | 1 | 1 | 0% | 3,783 | 6,215 | +64% | 0 | 0 | — |
case-03 | pass→pass | 4,252 | 6,013 | +41% | 1 | 1 | 0% | 639 | 3,547 | +455% | 0 | 0 | — |
case-04 | pass→pass | 5,684 | 4,782 | -16% | 1 | 1 | 0% | 1,070 | 3,326 | +211% | 0 | 0 | — |
case-05 | pass→pass | 3,868 | 4,074 | +5% | 1 | 1 | 0% | 531 | 3,110 | +486% | 0 | 0 | — |
case-06 | pass→pass | 5,440 | 6,925 | +27% | 1 | 1 | 0% | 1,008 | 3,578 | +255% | 0 | 0 | — |
case-07 | pass→pass | 4,177 | 4,467 | +7% | 1 | 1 | 0% | 632 | 3,042 | +381% | 0 | 0 | — |
case-08 | fail→pass | 7,921 | 5,085 | -36% | 1 | 1 | 0% | 793 | 3,014 | +280% | 0 | 0 | — |
case-09 | pass→pass | 5,497 | 6,150 | +12% | 1 | 1 | 0% | 976 | 3,231 | +231% | 0 | 0 | — |
case-10 | pass→pass | 10,100 | 7,137 | -29% | 1 | 1 | 0% | 1,639 | 3,789 | +131% | 0 | 0 | — |
case-11 | pass→pass | 8,731 | 10,983 | +26% | 1 | 1 | 0% | 2,013 | 4,712 | +134% | 0 | 0 | — |
case-12 | pass→pass | 9,901 | 10,845 | +10% | 1 | 1 | 0% | 1,522 | 4,572 | +200% | 0 | 0 | — |
case-13 | pass→pass | 8,596 | 9,398 | +9% | 1 | 1 | 0% | 1,441 | 4,021 | +179% | 0 | 0 | — |
case-14 | pass→pass | 4,795 | 7,946 | +66% | 1 | 1 | 0% | 868 | 3,562 | +310% | 0 | 0 | — |
case-15 | pass→pass | 6,919 | 6,740 | -3% | 1 | 1 | 0% | 1,065 | 3,636 | +241% | 0 | 0 | — |
case-16 | pass→pass | 3,532 | 4,289 | +21% | 1 | 1 | 0% | 697 | 3,138 | +350% | 0 | 0 | — |
case-17 | pass→pass | 10,521 | 10,780 | +2% | 1 | 1 | 0% | 2,086 | 4,527 | +117% | 0 | 0 | — |
case-18 | pass→pass | 6,292 | 4,788 | -24% | 1 | 1 | 0% | 1,050 | 2,945 | +180% | 0 | 0 | — |
case-19 | pass→pass | 15,065 | 11,533 | -23% | 1 | 1 | 0% | 2,419 | 4,665 | +93% | 0 | 0 | — |
case-20 | pass→pass | 15,687 | 17,466 | +11% | 1 | 1 | 0% | 3,273 | 5,961 | +82% | 0 | 0 | — |
case-21 | pass→pass | 12,373 | 9,500 | -23% | 1 | 1 | 0% | 2,097 | 4,217 | +101% | 0 | 0 | — |
case-22 | pass→pass | 15,254 | 16,197 | +6% | 1 | 1 | 0% | 3,103 | 5,631 | +81% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.