Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WSADATA wsa;
- if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0)
- {
- std::cout << "ERROR: WSAStartup failed" << std::endl;
- std::cin.get();
- }
- SOCKET s;
- if ((s = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
- {
- std::cout << "ERROR: Can't create socket - " << WSAGetLastError() << std::endl;
- std::cin.get();
- }
- struct sockaddr_in server;
- server.sin_family = AF_INET;
- server.sin_addr.s_addr = inet_addr("127.0.0.1");
- server.sin_port = htons(31001);
- if (connect(s, (struct sockaddr*)&server, sizeof(server)) < 0)
- {
- std::cout << "ERROR: Can't connect to server" << std::endl;
- std::cin.get();
- }
- std::cout << "INFO: Connected to server" << std::endl;
- std::cin.get();
- // Now we can send/receive data
- closesocket(s);
- WSACleanup();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement