程序源码如下,请耐心看一下,谢谢
#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,裡面有兩個文件,一般情況下,這個目錄就在你執行編譯的當前目錄下。如果你沒有發現這個目錄,那就是你取得程式碼不全。