Paul Sherman (paul++at++bham-ht.bioc.uab.edu)
Mon, 11 Aug 1997 09:30:25 -0500 (CDT)
Sam,
One way to solve this is to read from the socket until you have the correct
size of a packet read in (it sounds like you always know that you have 6
floats) and then translate that packet. If you have the socket read do its
read into a buffer and then translate the buffer after you are certain that
you have a complete packet, then you can avoid the attempted translation of
partial packets. In other words, do something like:
while(simNotDone)
{
while (packetNotComplete)
{
while ((cnt = read(into_a_buffer...) > 0);
check for a complete packet;
}
translate the packet;
perform bookkeeping on the possible partial packet left in the buffer;
}
Of course there is alot more bookkeeping involved in this, since depending on
your code, it is possible to read packet fragments and these need to be kept
track of...
However, one approach which we have been using recently which appears to be
faster and more robust than sockets is to use fifos (or named pipes). This
approach avoids the whole network layer inherant in sockets. So far, the code
is a little unstable on MP machines during startup (deadlock conditions in
opens), but once running, the code works perfectly (tested on a 2 Proc IR and
a 4 proc Onyx 2). For details, check out "Unix Network Programming" by
W. Richard Stevens (Prentice Hall), Chapter 3.
Hope this helps, and email me with any questions (see below).
Paul Sherman
psherman++at++acm.org
===========================================================================
Please note that the email to reply to is: psherman++at++acm.org. The email
addresses paul++at++ht.com and paul++at++bham-ht.bioc.uab.edu will not be valid past
Thursday August 14, 1997. I am changing jobs and will not know my new email
until after September 1. I will be able to read email sent to
psherman++at++acm.org. My email responses during the last two weeks of August may
be slow due to my travelling across the country.
===========================================================================
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:55:43 PDT