void MSAConnection::doRead(void) { MSBuffer *hb=headBuffer() ; MSBuffer *db=readBuffer() ; int s,n; if (isSet(MSProtocolConnection<MSA>::Reset)==MSTrue) return; if((s=hb->put()-hb->get())<4) { if((n=readTheBuffer(hb,4-s))<0) return; if((s=hb->put()-hb->get())<4) return; _bytesToNextMessage=MSA::longAt(hb->get()); if (_bytesToNextMessage<=0) { hb->reset(); unset(MSProtocolConnection<MSA>::Read); return; } } if((n=readTheBuffer(db,_bytesToNextMessage))<0) return; if((_bytesToNextMessage-=n)==0) { MSA d=MSA::importAObject( (char *) db->get(), db->put()-db->get(), (char *)0); hb->reset(); db->clear(); unset(MSProtocolConnection<MSA>::Read); if(d.isNullMSA()==MSTrue){resetWithError(MSProtocolConnection<MSA>::Read);return;} readNotify(d); } return; }
int MSAConnection::doSyncRead(MSA &result_) { MSBuffer *hb=headBuffer(); MSBuffer *db=readBuffer(); int s,n; if (isSet(MSProtocolConnection<MSA>::Reset)==MSTrue) return 0; if ((s=hb->put()-hb->get())<4) { if ((n=readTheBuffer(hb,4-s))<0) return 0; if((s=hb->put()-hb->get())<4) return 0; _bytesToNextMessage=MSA::longAt(hb->get()); } if((n=readTheBuffer(db,_bytesToNextMessage))<0) return 0; if((_bytesToNextMessage-=n)==0) { result_=MSA::importAObject((char *) db->get(), db->put()-db->get(), (char *)0); hb->reset(); db->clear(); unset(MSProtocolConnection<MSA>::Read); if((result_.aStructPtr())==(MSAStruct *)0){resetWithError(MSProtocolConnection<MSA>::Read);return 0;} } return 1; }
MSA MSAConnection::getAobjectFromBuffer(MSBuffer *buf_) { MSBuffer *hb=headBuffer(); MSBuffer *db=readBuffer(); int s,n; if (isSet(MSProtocolConnection<MSA>::Reset)==MSTrue) return MSA(); if((s=hb->put()-hb->get())<4) { if((n=MSBuffer::buffToBuff(buf_,hb,4-s))<0) return MSA(); if((s=hb->put()-hb->get())<4) return MSA(); _bytesToNextMessage=MSA::longAt(hb->get()); if (_bytesToNextMessage<=0) { hb->reset(); unset(MSProtocolConnection<MSA>::Read); return MSA(); } } if((n=MSBuffer::buffToBuff(buf_,db,_bytesToNextMessage))<0) return MSA(); if((_bytesToNextMessage-=n)==0) { MSA d=MSA::importAObject( (char *) db->get(), db->put()-db->get(), (char *)0); hb->reset(); db->clear(); unset(MSProtocolConnection<MSA>::Read); if(d.isNullMSA()==MSTrue) { resetWithError(MSProtocolConnection<MSA>::Read);return MSA(); } return d; } return MSA(); }
void MSRawConnection::doRead(void) { int n; MSBuffer *db=headBuffer(); if (isSet(MSProtocolConnection<MSString>::Reset)==MSTrue) return; if((n=readTheBuffer(db,MaxReadSize))<0) return; if((n=db->put()-db->get())>0) { unset(MSProtocolConnection<MSString>::Read); MSString d(db->get(),n); db->get(db->get()+n); readNotify(d); } }
int MSRawConnection::doSyncRead(MSString &result_) { MSBuffer *db=headBuffer(); int n; if (isSet(MSProtocolConnection<MSString>::Reset)==MSTrue) return 0; if ((n=readTheBuffer(db,MaxReadSize))<0) return 0; if((n=db->put()-db->get())>0) { unset(MSProtocolConnection<MSString>::Read); result_=MSString(db->get(),n); db->get(db->get()+n); } return 1; }
I pString_Connection::syncDoRead(A *pdataobj) { I result; MSBuffer *hb=headBuffer(); MSBuffer *db=readBuffer(); ipcWarn(wrnlvl(),"%t pString_Connection::syncDoRead\n"); *pdataobj=readOne(); if(*pdataobj==(A)0) { if(isInReset()) result=syncFillError("reset","Reset occurred. No message read."); else result=0; } else result=1; return result; }
A pSimple_Connection::getAobjFromBuffer(MSBuffer *bb) { ipcWarn(wrnlvl(),"%t pSimple_Connection::getAobjFromBuffer\n"); MSBuffer *hb=headBuffer(); MSBuffer *db=readBuffer(); A d,z; I s; if(4>(s=hb->put()-hb->get())) { if(0>bufftobuff(bb,hb,4-s)) R(A)0; if(4>(s=hb->put()-hb->get())) R(A)0; s=longAt(hb->get()); if(0>=s) { static char fmt[]="\343 IPC warning: zero-length message found. s=%d [%d]\n"; Warn(fmt, s,handle()); hb->reset(); turnInReadOff(); R(A)0; } // create read buffer, doubled as A-object char array d=gv(Ct,s); db->minofbuffer((C *)d); db->get(db->minofbuffer()); db->put((C *)(d)); db->maxofbuffer(db->put()+s); } if(0>bufftobuff(bb,db,db->maxofbuffer()-db->put())) R(A)0; if(db->put()==db->maxofbuffer()) { z=(A)db->minofbuffer(); z->c=1; hb->reset(); db->minofbuffer(0); db->clear(); return z; } R(A)0; }
A pSimple_Connection::readOne(void) { ipcWarn(wrnlvl(),"%t pSimple_Connection::readOne\n"); MSBuffer *hb=headBuffer(); MSBuffer *db=readBuffer(); int slen; A d,z=(A)0; if(4>(slen=hb->put()-hb->get())) { if(0>readTheBuffer(hb,4-slen)) return (A)0; if(4>(slen=hb->put()-hb->get())) return (A)0; slen=longAt(hb->get()); if(0>=slen) { static char fmt[]="\343 IPC warning: zero-length simple message. slen=%d [%d]\n"; Warn(fmt, slen,handle()); hb->reset(); turnInReadOff(); return (A)0; } d=gv(Ct,slen); db->minofbuffer((C *)d); db->get(db->minofbuffer()); db->put((C *)(d)); db->maxofbuffer(db->put()+slen); } if(0>readTheBuffer(db,db->maxofbuffer()-db->put())) return (A)0; if(db->put()==db->maxofbuffer()) { z=(A)db->minofbuffer(); z->c=1; hb->reset(); db->minofbuffer(0); db->clear(); return z; } return (A)0; }