int MSAConnection::syncSend(const MSA &v_,int seconds_,int microseconds_,MSBoolean isAbsolute_) { if (isSet(MSProtocolConnection<MSA>::Reset)==MSTrue) return 0; struct timeval timeout, now, tvp; if (isAbsolute_==MSTrue) { if (0 > microseconds_) return 0; tvp.tv_sec=seconds_; tvp.tv_usec=microseconds_; } else { gettimeofday(&now,NULL); timeout.tv_sec=seconds_; timeout.tv_usec=microseconds_; tvsum(&now,&timeout,&tvp); } if(writeChannel()==0) { MSMessageLog::errorMessage("MSAConnection: No Write Channel\n"); return 0; } MSBuffer *b=exportAObject(v_); if (b==NULL) return 0; sendTheBuffer(b); return syncWriteSelectLoop(&tvp); }
int MSRawConnection::syncSend(const MSString &aString_,int seconds,int microseconds,MSBoolean isAbsolute) { if (isSet(MSProtocolConnection<MSString>::Reset)) return 0; struct timeval timeout, now, tvp; if (isAbsolute==MSTrue) { if (0 > microseconds) return 0; tvp.tv_sec=seconds; tvp.tv_usec=microseconds; } else { gettimeofday(&now,NULL); timeout.tv_sec=seconds; timeout.tv_usec=microseconds; tvsum(&now,&timeout,&tvp); } if(writeChannel()==0) { MSMessageLog::errorMessage("MSRawConnection::syncSend: No Write Channel\n"); return 0; } MSBuffer *b=new MSBuffer; if (b==NULL) return 0; b->stuff(aString_.string(),aString_.length()); sendTheBuffer(b); return syncWriteSelectLoop(&tvp); }
A pString_Connection::syncSendCover(A msg_, A aTimeout) { struct timeval gameover, *tvp; I rc; ipcWarn(wrnlvl(),"%t pString_Connection::syncSend\n"); tvp = atotv(aTimeout, &gameover); if(writeChannel()==0) return syncErrorResult("nochan","channel is null"); /* put stuff on queue */ int dataSize = msg_->n; int bufferSize = HeaderLength +dataSize; int temp = htonl(dataSize); MSBuffer *sb=new MSBuffer( bufferSize); if(NULL==sb) return syncErrorResult("Buffer","new MSBuffer routine failed."); sb->stuff((char *)(&temp), HeaderLength); sb->stuff((const char *)msg_->p, dataSize); sendTheBuffer(sb); /* while loop on select() until timeout or write queue empty */ rc=syncWriteLoop(tvp); if(0>rc) return syncErrorResult(errorSymbol,errorMessage); else return gvi(Et,3,gsym("OK"),gi(rc),writeQueueStatus()); }
int MSAConnection::send(const MSA &v_) { if (isSet(MSProtocolConnection<MSA>::Reset)==MSTrue) return MSFalse; if (readChannel()==0) return 0; MSBuffer *b=exportAObject( v_); if (b==NULL) return MSFalse; sendTheBuffer(b); if (isSet(MSProtocolConnection<MSA>::WritePause)==MSFalse) writeChannel()->enable(); // attempt to immediately write buffer return doWrite(MSFalse); }
int MSRawConnection::send(const MSString& aString_) { if (isSet(MSProtocolConnection<MSString>::Reset)==MSTrue) return MSFalse; if (readChannel()==0) return MSFalse; MSBuffer *pBuffer=new MSBuffer; pBuffer->stuff(aString_.string(),aString_.length()); sendTheBuffer(pBuffer); if (isSet(MSProtocolConnection<MSString>::WritePause)==MSFalse) writeChannel()->enable(); // attempt to immediately write the buffer return doWrite(MSFalse); }
int pString_Connection::send(const A &msg_) { ipcWarn(wrnlvl(),"%t pString_Connection::send\n"); if(isInReset()||readChannel()==0) return -1; if(Ct!=msg_->t) return -1; MSBuffer *sb=new MSBuffer(msg_->n+sizeof(int)); if(NULL==sb) return -1; int msgLen=htonl((int)msg_->n); sb->stuff((char *)(&msgLen),sizeof(int)); sb->stuff((const char *)msg_->p, msg_->n); sendTheBuffer(sb); if (MSFalse==isWritePause()) writeChannel()->enable(); return doWrite(MSFalse); }
int pSimple_Connection::send(const A &msg_) { ipcWarn(wrnlvl(),"%t pSimple_Connection::send\n"); if(isInReset()||readChannel()==0) return -1; if(Et<=msg_->t) return -1; long len=AH+Tt(msg_->t,msg_->n)+((Ct==msg_->t)?1:0); MSBuffer *sb=new MSBuffer(len+sizeof(long)); if(NULL==sb) return -1; long msgLen=htonl(len); sb->stuff((char *)(&msgLen),sizeof(long)); sb->stuff((const char *)msg_, len); sendTheBuffer(sb); if (MSFalse==isWritePause()) writeChannel()->enable(); return doWrite(MSFalse); }