'sup.
Me and my friend recently began programming an IRC-client/bot. Everything went quite fine, until we realized that the server suddenly stopped reading our messages.
Well, I figured, we must've done something wrong. So I set up a sever-program and connected the client with it. After some foul debugging, I discovered that our \r\n (CR+LF) at the end of every sf::SocketTCP::Send() got ouputed as something more like \n\0. A newline and a nul, that is.
This is probably why the server kept ignoring our messages.
I've been able to recreate the situation with a few lines of code. It would be wonderful if anyone could review it and find any particular errors that might be the cause of this strange behaviour.
#include <SFML/System.hpp>
#include <SFML/Network.hpp>
#include <iostream>
int main()
{
sf::IPAddress ip("127.0.0.1");
sf::SocketTCP mainSocket;
mainSocket.Connect(6667,ip.ToString());
std::string buffer("This is a test.\r\n");
mainSocket.Send(buffer.c_str(),sizeof(char) * (buffer.size() + 1));
std::cout << "Sent the stuff. Terminating...";
return 0;
}
As of why I am using std::string as a buffer, It's necessary to get what I want in the real troublemaking app. I certainly hope it's not the cause.
(In fact it can't be. I see the same thing when using a non-converted char buffer)
Another thing that might be relevant, is that my home-made server (the one I used for testing and debugging) can't seem to read the whitespaces as regular 0x20 chars. However, when using a client made with another library, it can.
Like I said, I hope someone better than I can solve my issue.
Thanks in advance,
Fr4sbokz