标签:windows 客户端 include socket message
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
int main(int argc,char * argv[])
{
char message[30];
WSADATA wsaData;
SOCKET hSocket;
SOCKADDR_IN servAddr;
WSAStartup(MAKEWORD(2,2),&wsaData);
hSocket = socket(PF_INET,SOCK_STREAM,0);
memset(&servAddr,0,sizeof(servAddr));
servAddr.sin_family = AF_INET;
servAddr.sin_addr.s_addr = inet_addr(argv[1]);
servAddr.sin_port = htons(atoi(argv[2]));
connect(hSocket,(SOCKADDR *)&servAddr,sizeof(servAddr));
recv(hSocket,message,sizeof(message) - 1,0);
printf("%s",message);
closesocket(hSocket);
WSACleanup();
return 0;
}
标签:windows 客户端 include socket message
原文地址:http://aimoer.blog.51cto.com/12444596/1885972