Example of SocketGroup
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
#include <netlink/socket.h>
#include <netlink/socket_group.h>
const string HOST = "localhost";
const unsigned SERVER_PORT = 5000;
bool disconnect = false;
char buffer[256];
buffer[255] = '\0';
socket->
read(buffer, 255);
cout << "\nReceived message: " << buffer;
}
};
disconnect = true;
}
};
int main() {
cout << "\nConnecting...";
cout.flush();
try {
OnRead onRead;
OnDisconnect onDisconnect;
while(!disconnect) {
char input[256];
input[255] = '\0';
cout << "\n--> ";
cin.getline(input, 255);
if(!strcmp(input, "exit"))
disconnect = true;
else
socket.send(input, strlen(input)+1);
}
}
cout <<
"\n***ERROR*** " << e.
what();
}
}