home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.net;
-
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
-
- class SocketReader extends Thread {
- MPlex _mplex;
- InputStream _istrm;
- String _problem;
- byte[] _header;
- int _msgnum;
-
- SocketReader(MPlex mplex, InputStream stream) {
- this._mplex = mplex;
- this._istrm = stream;
- this._header = new byte[5];
- }
-
- public void run() {
- while(true) {
- String s = null;
- short streamID = (short)32767;
-
- try {
- int lenRecv = 0;
-
- for(int npass = 0; lenRecv < 5 && npass < 4; ++npass) {
- lenRecv += this._istrm.read(this._header, lenRecv, 5 - lenRecv);
- }
-
- if (this._header[0] == -69) {
- int msglen = this._header[2];
- if (msglen < 0) {
- msglen += 256;
- }
-
- msglen += (this._header[1] << 8) - 2;
- streamID = (short)this._header[4];
- if (streamID < 0) {
- streamID += 256;
- }
-
- streamID = (short)(streamID + (this._header[3] << 8));
- int ipos = 0;
- byte[] msgbufRecv = new byte[msglen];
-
- int savedMsglen;
- for(savedMsglen = msglen; msglen > 0; ipos += lenRecv) {
- lenRecv = this._istrm.read(msgbufRecv, ipos, msglen);
- msglen -= lenRecv;
- }
-
- if (streamID == 32766) {
- throw new IOException("IDLE TIMEOUT");
- }
-
- OutputStream ostr = this._mplex.getStream(streamID);
- if (ostr != null) {
- ostr.write(msgbufRecv, 0, savedMsglen);
- }
- }
- } catch (IOException var10) {
- streamID = (short)32767;
- String var11 = null;
- this._mplex.connectionLost(this);
- return;
- }
- }
- }
- }
-