[interfacekit] Port Messaging

What do you guys think about using BMessages to send extra data for sent 
messages? I'm in process of attempting to hash-out the messaging protocol for 
app-server communication. If this seems ok, could someone point out why the 
server-received message has no attachments? TIA

--DW


//----------------------------------------------

// Application code

        // Notify server of app's existence
        BMessage *createmsg=new BMessage(CREATE_APP);
        createmsg->AddString("signature",signature);
        createmsg->AddInt32("messageport",messageport);

        write_port(serverport,CREATE_APP,createmsg,sizeof(*createmsg));


//----------------------------------------------

// Server code
buffersize=port_buffer_size(messageport);
                
if(buffersize>0)
{
        msgbuffer=new uint8[buffersize];
        bytesread=read_port(messageport,&msgcode,msgbuffer,buffersize);
}
else
        bytesread=read_port(messageport,&msgcode,NULL,0);

if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != 
B_WOULD_BLOCK)
{
        switch(msgcode)
        {
                case CREATE_APP:
            // calling BMessage::PrintToStream within DispatchMessage
            // will show no attached data
                        DispatchMessage((BMessage *)msgbuffer);
                        break;
        default:
                printf("Server received unexpected code %ld\n",msgcode);
                        break;
        }
}
//------------------------------------------------------



Other related posts: