The problem I'm having with the socket selector is that it for some reason doesn't find that i have messages waiting to be received in the socket. I'm connecting to IRC and it works perfectly well to join channels and send messages, but for some reason I am getting no messages back to my own client. ( I know that it is working to join channels and all that because i have another client open on the side that my own made client sends private messages and such to ) I have tried for many hours now to get it working but for some reason it just wont work. I'm hoping that someone can help me. Here is a minimal example
int main()
{
sf::TcpSocket client;
sf::SocketSelector selector;
queue<string> msgQueue;
msgQueue.push("NICK brewdal \n\rUSER testing 0 * :browdal\n\rJOIN #testthis\n\r");
msgQueue.push("PRIVMSG #testthis :hallo\n\r");
msgQueue.push("PRIVMSG Brodal :Hello you\n\r");
selector.add(client);
sf::Socket::Status status = client.connect("irc.freenode.net", 6667);
if ( status != sf::Socket::Done )
cout << "Failed to connect to the specified server" << endl;
while ( true )
{
if ( selector.wait(sf::seconds(0.1f)) )
{
if ( selector.isReady(client) )
{
char buffer[512];
size_t received = 0;
client.receive(buffer, 512, received);
buffer[received] = '\0';
cout << buffer << endl;
}
}
else if ( !msgQueue.empty() )
{
status = client.send(msgQueue.front().c_str(),msgQueue.front().size());
if ( status != sf::Socket::Done )
{
cout << "Failed to send message" << endl;
}
else
{
msgQueue.pop();
}
}
}
return EXIT_SUCCESS;
}
I have also tried using a wide variety of different times in the if ( selector.wait() ) and I have also tried infinite time but I still am not getting any messages.