Hi,
I tried to create my little chat bash (following this tutorial for sockets :
http://tldp.org/LDP/LG/issue74/tougher.html)
And i have a problem when I do my getline(cin, output) on a separated thread.
I can't find a complete article that explains how make a chat in c++ <u>on Linux</u>
So I made it following this logic :
When connection is established between server and client:
- launch a new thread with a getline(cin, output) to listen for keyboard input
- in main thread: Socket::read() waiting for incoming stream
Is it the best manner to do ?
I think that my problem (eated line) is caused by the multi-thread and the std:cin class
Here you have my source code (compiled on Ubuntu 16.04) :
https://mega.nz/#!mhA1xbaS!ebyf3ZhWuSs9T5Z_h7XGnmuJrysioNIrPBTHPPewZaM
Sorry for my bad English, I tried to do my best to explain myself.
To test iit: You have to launch 2 terminals. The first launches the server ("./simple_server") and then on the second, you can launch the client("./simple_client")
Thank you !