Below is my client side code. I just created simple client server. Client connect to server and send messages.Server implement callback messages and displays it.
Now I need to know how to do the following?
1) Both must connect through FIFO and make sync async calls and send data
2) How to create a class with certain attributes which will be custom? Basically need to store custom objects.
Code:
#include <iostream>
#include <fstream>
#include "SocketClient.h"
using namespace std;
void onError(errorStruct *e)
{
cout << e->message << endl;
}
int main()
{
SocketClient client("127.0.0.1", 5555);
client.setErrorCallback(onError);
client.connect();
string str;
while(1)
{
cout << ">";
getline(cin, str);
client.send(str);
}
/* NEW */ // You can now send streams this way
ifstream file("/path/to/file");
client.send(file); // The server will receive the STRING CONTENT of the file.
// But I'm working on a new version to receive the whole file directly (not as a string)
/* NEW */
client.close();
}