TOBI plaform TCP client example.
#include <cstdio>
#include <iostream>
#include <unistd.h>
#include <tobiplatform/TPSocket.hpp>
#include <tobicore/TCTime.hpp>
int main(void) {
std::string message;
socket.
Connect(
"127.0.0.1",
"8001");
socket.
Send(
"My dear server, here you go.\n");
ssize_t bytes = 0;
while(true) {
bytes = socket.
Recv(&message);
if(bytes > 0)
std::cout << "Received [" << bytes << "]: " << message << std::endl;
else {
socket.
Send(
"My dear server, here you go again.\n");
}
}
return 0;
}