Created
November 6, 2012 13:48
-
-
Save neuro-sys/4024835 to your computer and use it in GitHub Desktop.
winsock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <Ws2tcpip.h> | |
| #pragma comment (lib, "Ws2_32.lib") | |
| int main() | |
| { | |
| WSADATA wsaData; | |
| struct addrinfo hint; | |
| struct addrinfo *res; | |
| int sockfd; | |
| WSAStartup(MAKEWORD(2,1), &wsaData); | |
| memset(&hint, sizeof(hint), 0); | |
| hint.ai_family = AF_UNSPEC; | |
| hint.ai_protocol = SOCK_STREAM; | |
| GetAddrInfo("irc.freenode.net", "6667", &hint, &res); | |
| sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); | |
| connect(sockfd, res->ai_addr, res->ai_addrlen); | |
| WSACleanup(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment