[interfacekit] Re: BSession(NG)

BTW, excuse me if you know already but read_port() is not like a socket or file 
descriptor. You
will lose data if the bufferSize is too small. You can't read_port() twice on 
the same message.

read_port(port_id id, int32 *protocol, void *msgBuffer, size_t bufferSize);

So with your code, the receiver better have set a buffersize larger than or 
equal to what the
sender set. This is an ugly dependency. Please don't tell me we can solve it 
with pretty
documentation :-)

IMO, the solution is to dynamically resize the receive buffer if necessary...

You can call port_buffer_size() to find out the size of the message before 
read_port();

ssize_t port_buffer_size(port_id id);

It's simple, it works. One malloc() call or none if the buffer is already large 
enough.



        
                
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

Other related posts: