程序源码如下,请耐心看一下,谢谢
#include "stdafx.h"
#include <string>
#include <iostream>
#include "PSocket/PSocket.hpp"
#include "PSocket/PClient.hpp"
using namespace std;
int main(void) {
PClient client;
client.setNotDelay();
client.setSendBuf(0);
string serverAddr,
serverPort;
cout << "Input server address: ";
cin >> serverAddr;
cout << "Input server port: ";
cin >> serverPort;
if (client.connectTo(serverAddr.c_str(), serverPort.c_str())) {
cout << "Connect success" << endl;
for (;;) {
cout << "\n>";
const unsigned int inputBufLen = 2048;
char inputBuf[inputBufLen];
cin.getline(inputBuf, inputBufLen);
string input = string(inputBuf);
client.sendBytes(input.c_str(), input.length());
client.sendBytes("\0", 1);
int revLen;
string revStr = "";
for (;;) {
const int bufLen = 1024;
char buf[bufLen];
revLen = client.getBytes(buf, bufLen);
if (revLen > 0) {
revStr += string(buf, (size_t)revLen);
if (buf[revLen - 1] == 0) {
break;
}
}
else {
break;
}
}
if (revStr.length() > 0) {
cout << revStr << endl;
}
if (input == "/disconnect") {
cout << "Disconnect" << endl;
break;
}
}
}
else {
cout << "Connect failed" << endl;
}
return 0;
}
这两行是什么东西,哪里能找到呢
#include "PSocket/PSocket.hpp"
#include "PSocket/PClient.hpp"
高洛峰2017-04-17 13:44:15
PSocket/PClient.hpp PSocket/PSocket.hpp应该是存在一个目录名叫PSocket,里面有两个文件,一般情况下,这个目录就在你执行编译的当前目录下。如果你没有发现这个目录,那就是你获取代码不全。