CPPUNIT_TEST(UnixCommToServer);
CPPUNIT_TEST(UnixCommToServerAndBack);
+ CPPUNIT_TEST(IPCommToServer);
CPPUNIT_TEST_SUITE_END();
}
}
+ void IPCommToServer()
+ {
+ pid_t pid;
+ string data;
+
+ switch(pid=fork())
+ {
+ case -1:
+ {
+ CPPUNIT_FAIL("fork error");
+ break;
+ }
+ case 0:
+ // child
+ {
+ // wait till server is up
+ sleep(1);
+ socket_client_connection sc("localhost",6666,socket_client_connection::max_retries_default);
+ sc.write("hello");
+ // don't call atexit and stuff
+ _exit(0);
+ }
+
+ default:
+ // parent
+ {
+ socket_server ss(6666);
+
+ // max 10 sec
+ for (int i=0; i < 10; i++)
+ {
+ ss.fill_buffer(1000000);
+
+ if(ss.get_packet(data))
+ break;
+ }
+ }
+ }
+ CPPUNIT_ASSERT_EQUAL(string("hello"),data);
+ }
+
};
CPPUNIT_TEST_SUITE_REGISTRATION(test_comm);