I am a newbie in network programming, so this can be a stupid question. I am trying to program a server which gets messages from a simple client every 1 second. After a few messages are sent successfully to the server, "software caused connection abort" exception is thrown. I guess I am doing something fundamentally wrong. I couldn't figure out what is wrong.
Client looks like:
- Code: Select all
StreamSocket ss;
ss.connect(SocketAddress("localhost", m_heartBeatPort));
for( int i = 0 ; i < 5 ; i++ )
{
std::cout << "Testexe.exe is counting " << i << "/5" << std::endl;
std::string msg = m_heartBeatStr + Poco::NumberFormatter::format(i);
ss.sendBytes( msg.c_str(), msg.size() );
Poco::Thread::sleep(1000);
}
and the listening server thread is:
- Code: Select all
void ListeningServerThread::run()
{
_ready.set();
Poco::Net::ServerSocket serverSocket(SocketAddress("localhost", m_port));
Poco::Timespan span(250000);
while( !_stop )
{
// Read message from sender
if (serverSocket.poll(span, Socket::SELECT_READ))
{
StreamSocket ss = serverSocket.acceptConnection();
char buffer[256];
int n = ss.receiveBytes(buffer, sizeof(buffer));
}
}
}





