#include<winsock2.h>#include<stdio.h>#include<conio.h>#include<stdlib.h>#pragmacomment(lib,"ws2_32.lib")char receiveBuf[1024];char sendBuf[1024];intmain(){
int err;
WORD versionRequired;
WSADATA wsaData;
versionRequired=MAKEWORD(2,2);
err=WSAStartup(versionRequired,&wsaData);if(!err){
printf("The socket of Client has opened!\n");}else{
printf("The socket of Client failed to open!\n");return0;}
SOCKET clientSocket=socket(AF_INET,SOCK_STREAM,0);char ip_s[100];printf("Please input the IP of Server!\n");scanf("%s",ip_s);
SOCKADDR_IN clientsock_in;
clientsock_in.sin_addr.S_un.S_addr=inet_addr(ip_s);
clientsock_in.sin_family=AF_INET;
clientsock_in.sin_port=htons(6000);connect(clientSocket,(SOCKADDR*)&clientsock_in,sizeof(SOCKADDR));char r_or_s;while(1){
printf("Input the operation char! Input ; to close the Client!\n");fflush(stdin);scanf("%c",&r_or_s);printf("The client input %c!\n",r_or_s);if(r_or_s=='r'||r_or_s=='R'){
recv(clientSocket,receiveBuf,sizeof(char)*1024,0);printf("%s\n",receiveBuf);}elseif(r_or_s=='s'||r_or_s=='S'){
printf("Input the information to Server!\n");scanf("%s",sendBuf);send(clientSocket