Logo Search packages:      
Sourcecode: rserve version File versions  Download package

Rpacket org::rosuda::JRclient::Rtalk::request ( int  cmd,
byte[]  prefix,
byte[]  cont,
int  offset,
int  len 
) [inline]

sends a request with attached prefix and parameters. Both prefix and cont can be null. Effectively request(a,b,null) and request(a,null,b) are equivalent.

cmd command - a special command of -1 prevents request from sending anything
prefix - this content is sent *before* cont. It is provided to save memory copy operations where a small header precedes a large data chunk (usually prefix conatins the parameter header and cont contains the actual data).
cont contents
offset offset in cont where to start sending (if <0 then 0 is assumed, if >cont.length then no cont is sent)
len number of bytes in cont to send (it is clipped to the length of cont if necessary)
returned packet or null if something went wrong

Definition at line 181 of file Rtalk.java.

References getInt(), and setInt().

        if (cont!=null) {
            if (offset>=cont.length) { cont=null; len=0; }
            else if (len>cont.length-offset) len=cont.length-offset;
        if (offset<0) offset=0;
        if (len<0) len=0;
        int contlen=(cont==null)?0:len;
        if (prefix!=null && prefix.length>0) contlen+=prefix.length;
      byte[] hdr=new byte[16];
      for(int i=8;i<16;i++) hdr[i]=0;
      try {
          if (cmd!=-1) {
            if (prefix!=null && prefix.length>0)
            if (cont!=null && cont.length>0)

          byte[] ih=new byte[16];
          if (is.read(ih)!=16)
            return null;
          int rep=getInt(ih,0);
          int rl =getInt(ih,4);
          if (rl>0) {
            byte[] ct=new byte[rl];
                int n=0;
                while (n<rl) {
                    int rd=is.read(ct,n,rl-n);
            return new Rpacket(rep,ct);
          return new Rpacket(rep,null);
      } catch(Exception e) {
          return null;

Generated by  Doxygen 1.6.0   Back to index