#include <stdio.h>
#include <winsock2.h>
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
#pragma comment (lib,"ws2_32")
#define NAME_LEN 20
int main(int argc, char* argv[])
{
cout << "This is Client cmd" << endl;
WSADATA wsaData;
WSAStartup(MAKEWORD(2, 2), &wsaData);
//创建一个socket来连接服务端
SOCKET s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
sockaddr_in addr;
addr.sin_addr.S_un.S_addr = inet_addr("10.224.32.198");
addr.sin_family = PF_INET;
addr.sin_port = htons(3270);
//这条执行后,说明和服务端建立了连接
connect(s, (SOCKADDR*)&addr, sizeof(SOCKADDR));
//char Buff[MAXBYTE] = { 0 };
char Cmd[MAXBYTE] = { 0 };
//recv(s, Buff, MAXBYTE, 0);
//cout << "from server:" << Buff << endl;
//不断地给服务端发送信息
while (TRUE)
{
cin >> Cmd;
cout << "your input command is:" << Cmd << endl;
send(s, Cmd, strlen(Cmd), 0);
}
getchar();
WSACleanup();
return 0;
}