Advertisement
PifyZ

Server C

Aug 1st, 2014
524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <winsock2.h>
  4.  
  5. #define PORT 9002
  6.  
  7. void wait_key();
  8.  
  9. int main (int argc, char *argv[]) {
  10.     WSADATA wsa;
  11.     WSAStartup(0x22, &wsa);
  12.  
  13.     SOCKET listen_sock = INVALID_SOCKET;
  14.     listen_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  15.  
  16.     SOCKADDR_IN sock_addr = {
  17.         .sin_family      = AF_INET,
  18.         .sin_addr.s_addr = inet_addr("127.0.0.1"),
  19.         .sin_port        = htons(PORT)
  20.     };
  21.  
  22.     bind(listen_sock, (SOCKADDR *)&sock_addr, sizeof(sock_addr));
  23.  
  24.     listen(listen_sock, SOMAXCONN);
  25.  
  26.     printf("AAA\n");
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement