程序源码如下,请耐心看一下,谢谢
#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"
PSocket/PClient.hpp PSocket/PSocket.hpp should exist in a directory called PSocket with two files in it. Generally, this directory is in the current directory where you perform compilation. If you don't find this directory, then you have incomplete access to the code.