Okay, I typed up the code under the Networking tutorial for SFML and included <thread>
#include <iostream>
#include <thread>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include "ResourcePath.hpp"
using namespace sf;
using namespace std;
int main(){
RenderWindow window(VideoMode(800, 600), "SFML Networking - MarcuzPwnz");
cout << "Would you like to be a server or client? (c/s)" << endl;
char input = ' ';
cin >> input;
if(input == 'c'){
/* CLIENT */
TcpSocket socket;
socket.connect("localhost", 1337);
string message = "Hey, I'm the client!";
socket.send(message.c_str(), message.size() + 1);
char buffer[1024];
size_t received = 0;
socket.receive(buffer, sizeof(buffer), received);
cout << "[Server]: " << buffer << endl;
}else{
/* SERVER */
TcpListener listener;
listener.listen(1337);
TcpSocket socket;
listener.accept(socket);
cout << "Client connected: " << socket.getRemoteAddress() << endl;
char buffer[1024];
size_t received;
socket.receive(buffer, sizeof(buffer), received);
cout << "Client: " << buffer << endl;
string message = "Welcome client!";
socket.send(message.c_str(), message.size() + 1);
}
while(window.isOpen()){
Event event;
while(window.pollEvent(event)){
}
}
return 0;
}
The code runs fine without #include <thread> on the second line, but with it I get errors.
Error: Lexical or Preprocessor Issue. 'thread' file not found.
Thanks for the reply. :)
Your compiler is probably not configured properly.
What about this code, with the exact same setup (ie. don't create a new project to try it)?
#include <thread>
int main()
{
return 0;
}
Thanks!
I'll go and install the command line tools and try again :)
Also I recently got the latest version of Xcode so I could use C++11 and the feedback I got from terminal was:
Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix