void testPeerStatus()
	{
		send_socket->connect( "127.0.0.1", 65001);
		CPPUNIT_ASSERT( !send_socket->peerDisconnected() );
		send_socket->send( "", 1); // ok, no icmp received yet
		send_socket->send( "", 1); // icmp received, send fails
		CPPUNIT_ASSERT( send_socket->peerDisconnected() );
	}
	void testMulticast()
	{
		int ret;
		send_socket->setMulticastTTL(0);
		send_socket->connect( "224.40.0.1", 47777);
		recv_socket->bind(47777);
		recv_socket->joinGroup("224.40.0.1");

		ret = send_socket->send( send_msg, len);
		CPPUNIT_ASSERT_EQUAL( len, ret );
		ret = recv_socket->receive( recv_msg, len);
		CPPUNIT_ASSERT_EQUAL( len, ret );
		CPPUNIT_ASSERT( std::memcmp( send_msg, recv_msg, len) == 0 );

		recv_socket->leaveGroup("224.40.0.1");
		ret = send_socket->send( send_msg, len);
		CPPUNIT_ASSERT_EQUAL( len, ret );

		ret = recv_socket->timedReceive( recv_msg, len, 1);
		CPPUNIT_ASSERT_EQUAL( 0, ret );
	}
示例#3
0
	void onUDPClientSendTimer(void*)
	{
		std::string payload(util::itostr(time::ticks()));
		payload.append(UDPPacketSize - payload.length(), 'x');
		udpClientSock->send(payload.c_str(), payload.length(), udpServerAddr);
	}