Пример #1
0
int main(int argc, char** argv)
{
    (void)argc;
    (void)argv;

    if ( 0 )
    {
        char* test = strformat( "Hello, %s", argv[0] );
        printf( "%s\n", test );
        strfree( test );
    }

    if ( 1 )
    {
        disruptorKill( "benchmark" );
    }

    {
        int fd;
        bool child;

        if ( 1 )
            fd = fork();
        else
            fd = 0;
        child = (fd == 0);

        if ( 1 )
        {
            disruptorMsg m;
            disruptor* d = disruptorCreate( "benchmark", (child ? "clientB" : "clientA"), 16*1024 );

            disruptorPrintf( d, "hello, world!" );
            disruptorPrintf( d, "hello again, world!" );

            while ( (m = disruptorRecv( d )) )
            {
                int64_t time = msgGetTimestamp( d, m );
                int senderId = msgGetSenderId( d, m );
                const char* sender = msgGetSender( d, m );
                size_t size = msgGetSize( d, m );
                char* msg = msgGetData( d, m );
                printf( "received time=%lld sender=%s size=%d msg=%s\n",
                        time, sender, (int)size, msg );
            }

            disruptorRelease( d );
        }

        if ( !child )
        {
            int signal;
            wait( &signal );
        }
    }

    return 0;
}
Пример #2
0
bool BTCtcp::SendMsg_GetData(std::vector<uint256> &vHashes, int HashType)
{
	BTCMessage msgGetData(btcmsg_getdata, BTC_TestNetwork);
	// payload= count + inv vectors
	msgGetData.AppendVarInt(vHashes.size());
	// loop through each hash
	BOOST_FOREACH(uint256 &ui, vHashes)
	{
		msgGetData.AppendInvVector(HashType, ui);
	}