////////////////////////////
// 08.07.21 Simple_Client.cpp
////////////////////////////
#include<WINSOCK2.h>
#include<stdio.h>
#pragma comment(lib , "ws2_32.lib")
int main()
{
SOCKET sd;
SOCKADDR_IN ser_addr;
char buf[1024];
WSADATA data;
WSAStartup(0x0202 , &data);
sd = socket(AF_INET , SOCK_STREAM , 0);
ser_addr.sin_family = AF_INET;
ser_addr.sin_port = htons(8888);
//ser_addr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
ser_addr.sin_addr.S_un.S_addr = inet_addr("192.168.0.112");
memset(&ser_addr.sin_zero , 0 , sizeof(ser_addr.sin_zero));
connect(sd,(SOCKADDR*)&ser_addr , sizeof(ser_addr));
printf("message:");
gets(buf);
send(sd , buf , strlen(buf),0);
/////////////////////////////////////
memset(buf,0,sizeof(buf));
/////////////////////////////////////
int ret = recv(sd, buf, sizeof(buf),0);
buf[ret] = 0 ;
printf("[%s]\n",buf);
closesocket(sd);
WSACleanup();
return 0;
}