while ( (count>0) && (select_retval==1) && (total_count<32768) )
{
count=0;
int maxread=32768-total_count;
if (maxread>4096)
maxread=4096;