Greetings. After I discovered port forwarding, I decided to try to make my own server, for testing web things. This would be able to, unlike free hosts, offer more freedom, for obvious reasons, such as server-side scripting. Not to mention, I can learn a bunch - say, POP or HTTP and networking things - side by side with networking through the server for games and experimenting with HTML5 and such things.
Anyway, As I was testing the port forwarding, I was able to receive the HTTP requests fine, and regardless of what it said, I sent a test response back, with a rather basic page.
I am guessing my HTTP is pretty bad, but I DID manage to get something. IT appeared as though the browser decided to display everything I said it, as simple as possible. It did display the <p> element correctly. It read:
Some paragraph here...
Failed to set socket option "TCP_NODELAY" ; all your TCP packets will be bufferedFailed to enable broadcast on UDP socketCannot send data over the network (no data to send)Cannot receive data from the network (the destination buffer is invalid)vector::_M_fill_insertFailed to bind listener socket to port Failed to listen to port Failed to accept a new connection, the socket is not listening255.255.255.255www.sfml-dev.org/ip-provider.php˜6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@Â6@´6@Ÿ6@¦6@Â6@Â6@»6@Â6@Â6@6@vector::_M_fill_insert/GETPOSTHEAD HTTP/. : http/http://https://Fromuser@sfml-dev.orgUser-Agentlibsfml-network/2.xHostContent-LengthContent-Typeapplication/x-www-form-urlencodedConnectionclose$tI
Some paragraph here was my example <p> text, and is not actually another paragraph of relative information. AnywayI don't know where this content comes from, but I assume, somehow, SFML added this on, although I thought the error log normally redirected to the console, (like with a 0x0 texture). So I am pretty lost, but I don't think this is my doing. Anyway, my guess is, this message gets tacked in there with any HTTP/HTML, and so the browser is rather confused, and so making a proper server is a bit impossible till I fix this giberish. All I can assume is that it is an SFML sockets issue.
Not quite sure how to correctly format code in here, sorry.
int main()
{
sf::TcpSocket socket;
sf::TcpListener listener;
listener.listen(11111);
while (true)
{
if (listener.accept(socket) == sf::Socket::Done)
{
std::cout << "Connection!\n";
socket.setBlocking(true);
char buffer[1000];
sf::IpAddress other;
std::size_t t;
socket.receive(buffer, sizeof(buffer), t);
std::cout << buffer;
socket.send("HTTP 1.1 200 OK\n\rConnection: close"
"\n\r\n\r"
"<!DOCTYPE html><html><head><title>TestPage</title>"
"</head><body style = \"background-color: lightblue;\" >"
"<p>Some paragraph here...</p></body></html>\r\n"
, 1000);
}
sf::sleep(sf::seconds(0.01));
}
std::cin.get();
}
This with including SFML/Network and iostream, as well as linking with the SFML libs. I used Firefox and typed in the URL bar my external ip followed by :11111 (this rather than 80). I don't think it is a browser issue, though, because chrome displays about the same thing, although is gets the style = "background-color: lightblue" part correct as well.
Thanks if you can help.
EDIT: SFML2-rc from... a few months back. Might be useful information.