Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <winsock2.h>
- int main()
- {
- SOCKET mySocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- struct sockaddr_in mySocketAddr;
- mySocketAddr.sin_port = htons(1212);
- mySocketAddr.sin_family = AF_INET;
- mySocketAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
- int con = connect(mySocket,(struct sockaddr*)&mySocketAddr,sizeof(mySocketAddr));
- if (con == SOCKET_ERROR) {
- printf("Error connecting to socket with error %d.",con);
- } else {
- printf("Connection successful.")
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement