I have created a client-server architecture using Boost Asio.
The entire thing works, I can send and receive messages, etc, so there is no question about the correctness. However, when I implement it in a real network, all of a sudden it becomes VERY slow. When I run the server and client on the same computer itgoes blazingly fast, but when I run it on 2 different computers, it becomes exremely slow, I have to wait a second for each message. And these messages are SMALL maybe 50, 60 characters max. They are sent over correctly though.
The code:
stream = new tcp::iostream(serverIp, portNum); // Clientside
For sending and receiving I use:
(*stream) << data << delimiter;
std::getline(*stream, response, '#');
The server uses the same for sending and receiving, and some setup code for setting up the connection:
boost::asio::io_service io_service;
tcp::endpoint endpoint(tcp::v4(), portNum);
tcp::acceptor acceptor(io_service, endpoint);
for (;;)
{
tcp::iostream *stream = new tcp::iostream();
acceptor.accept(*(stream->rdbuf()));
// Do stuff with the stream
}
Again, it WORKS, just very slowly allof a sudden on a real network. Is there something I am doing wrong? I tried changing the portNum, didn't work. Anything else I can do?