fork download
  1. #include <stdio.h>
  2. #include <winsock2.h>
  3.  
  4. int main() {
  5.  
  6. WSADATA wsaData;
  7. SOCKET sock;
  8.  
  9. int result = WSAStartup(MAKEWORD(2, 2), &wsaData);
  10. struct sockaddr_in hints;
  11. char buf[8192];
  12.  
  13. memset(buf, 0, sizeof(buf));
  14. memset(&hints, 0, sizeof(struct sockaddr_in));
  15.  
  16. hints.sin_addr.s_addr = inet_addr("127.0.0.1");
  17. hints.sin_port = htons(9090);
  18. hints.sin_family = AF_INET;
  19.  
  20. sock = socket(AF_INET, SOCK_STREAM, 0);
  21. connect(sock, (struct addrinfo*)&hints, sizeof(hints));
  22.  
  23. recv(sock, buf, sizeof(buf), 0);
  24.  
  25. printf("%s", buf);
  26.  
  27. FILE * file;
  28. file = fopen("test.exe", "w");
  29. fprintf(file, buf);
  30. fclose(file);
  31.  
  32. return 0;
  33. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:2:22: fatal error: winsock2.h: No such file or directory
 #include <winsock2.h>
                      ^
compilation terminated.
stdout
Standard output is empty