socket communication
This commit is contained in:
parent
5f72e4ed57
commit
96ed50ece4
|
@ -51,8 +51,10 @@ namespace server {
|
|||
_acceptor.accept(socket);
|
||||
|
||||
myfile.open("TCP" + std::to_string(_port) + ".txt", std::ios::app);
|
||||
myfile << " Connected " << std::endl;
|
||||
myfile << " Message: " << message << " // length: " << message.length() << " // byte: "<< GetBytes(message.length()) <<std::endl;
|
||||
myfile.close();
|
||||
|
||||
|
||||
//Sleep(500);
|
||||
std::string outMessage (GetBytes(message.length()) + message);
|
||||
|
@ -68,12 +70,16 @@ namespace server {
|
|||
}
|
||||
|
||||
void TCPServer::readString(std::string &message, error_code &error) {
|
||||
myfile.open("TCP" + std::to_string(_port) + ".txt", std::ios::app);
|
||||
myfile << "--> READ <--" << std::endl;
|
||||
myfile << " Create socket " << std::endl;
|
||||
myfile.close();
|
||||
|
||||
tcp::socket socket(_service);
|
||||
_acceptor.accept(socket);
|
||||
|
||||
myfile.open("TCP" + std::to_string(_port) + ".txt", std::ios::app);
|
||||
myfile << "--> READ <--" << std::endl;
|
||||
myfile << " Create socket " << std::endl;
|
||||
myfile << " Connected " << std::endl;
|
||||
myfile.close();
|
||||
|
||||
for (;; ) {
|
||||
|
|
|
@ -47,6 +47,7 @@ namespace thread {
|
|||
_readQueue.wait_and_pop(value);
|
||||
_readJob(value);
|
||||
_writeQueue.push(_writeJob());
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace thread {
|
|||
T value;
|
||||
_queue.wait_and_pop(value);
|
||||
_job(value);
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace thread {
|
|||
void workerThread() {
|
||||
while (!_done) {
|
||||
_queue.push(_job());
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -140,14 +140,14 @@ int main(int argc, char* argv[]) {
|
|||
for (;;) {
|
||||
|
||||
Sleep(50);
|
||||
std::cout << "Sending..." << std::endl;
|
||||
//std::cout << "Sending..." << std::endl;
|
||||
auto time = daytimeString();
|
||||
// server.reward = testData;
|
||||
server.sendReward(testData);
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
Sleep(50);
|
||||
std::cout << "Listening..." << std::endl;
|
||||
//std::cout << "Listening..." << std::endl;
|
||||
float steer, gas;
|
||||
if (server.tryReadControl(steer, gas)) {
|
||||
/*if ((message == "q") || (message == "quit"))
|
||||
|
|
Loading…
Reference in New Issue