Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <winsock2.h>
  4.  
  5. int main()
  6. {
  7.     SOCKET mySocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  8.     struct sockaddr_in mySocketAddr;
  9.     mySocketAddr.sin_port = htons(1212);
  10.     mySocketAddr.sin_family = AF_INET;
  11.     mySocketAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
  12.  
  13.  
  14.     int con = connect(mySocket,(struct sockaddr*)&mySocketAddr,sizeof(mySocketAddr));
  15.  
  16.     if (con == SOCKET_ERROR) {
  17.         printf("Error connecting to socket with error %d.",con);
  18.     } else {
  19.         printf("Connection successful.")
  20.     }
  21.  
  22.     return  0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement