16.01.2013 Views

Downloading

Downloading

Downloading

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

258 C Helper Classes for Accessing MDSplus from Java<br />

s.writeByte( dtype );<br />

s.writeByte( client type );<br />

s . writeByte ( ndims );<br />

for<br />

{<br />

( i = 0; i < MDSDescriptor .MAX DIM ; i ++ )<br />

s.writeInt( dims[i ] );<br />

}<br />

s . write ( body , 0 ,<br />

s. flush ();<br />

message id ++;<br />

length ) ;<br />

}<br />

/∗ Receive the response from the MDSplus server .<br />

Decode and store<br />

the header of this message ∗/<br />

public void receive ( DataInputStream s )<br />

throws IOException<br />

{<br />

byte header [] =<br />

new byte [16 + 4 ∗ MDSDescriptor .MAX DIM ] ;<br />

int i;<br />

s. readFully(header );<br />

client type = header [14];<br />

compressed = (( client t y p e & COMPRESSED) ==<br />

COMPRESSED ) ;<br />

msglen = byteArrayToInt ( header , 0);<br />

status = byteArrayToInt ( header , 4);<br />

length = byteArrayToShort ( header , 8);<br />

nargs = header [10];<br />

descr idx = header [11];<br />

message id = header [12];<br />

dtype = header [13];<br />

client type = header [14];<br />

ndims = header [15];<br />

for<br />

{<br />

( i = 0; i < MDSDescriptor .MAX DIM ; i ++ )<br />

dims[ i ] = byteArrayToInt ( header , 16 + 4∗ i);<br />

}<br />

if ( msglen > 48 )<br />

{<br />

if ( compressed )<br />

{<br />

body = readCompressedBytes ( msglen − 52, s );<br />

}<br />

else<br />

{<br />

body = new byte [ msglen − 48];<br />

s. readFully(body);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!