Advertisement
Guest User

Untitled

a guest
Apr 21st, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <windows.h>
  2. #include <winsock2.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <iostream>
  6. #define BACKLOG 5
  7. using namespace std;
  8.  
  9.  
  10. int main()
  11. {
  12. char buf[MAX_PATH];
  13. WSADATA wsaData;
  14. WSAStartup(MAKEWORD(1, 1), &wsaData);
  15. SOCKET hServer = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
  16. SOCKADDR_IN sai;
  17. sai.sin_family = AF_INET;
  18. sai.sin_addr.s_addr = INADDR_ANY;
  19. sai.sin_port = htons(1337);
  20. bind(hServer,(LPSOCKADDR)&sai,sizeof(struct sockaddr));
  21. listen(hServer,10);
  22. SOCKET hClient = accept(hServer,NULL,NULL);
  23. while(1==1){
  24. recv(hClient,buf,sizeof(buf),0);
  25. cout << buf;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement