Msg Receiving Through Socket some problem
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   rajamca_s
Posted On:   Thursday, November 20, 2003 01:27 AM

Dear Sir, Actually I'm Reading Msg from Socket Sent by C++ Program (Server),It will send 2 msgs/sec.the msg format is like is |1118|0074|01|0023 |1234 |MIG|11FTR01|0eT0000023000318|000050|R|sampl eT msg Ref 0023000318;#STEPSD45C4F1E13A23CFB2DEAC4CBB6F4DD42E44BAB47F8944CF8F77ACB035F4D0652F2695D0A995240124CFEB539773551648F3A0118620DD293BD8EA139AB3BCE2ACDC4454B437E7C57618F97AB7E177C99B03D1D37D9119A16D8428025FEE1E4C93BEC9AE4275E86A22594CB739FFAFDB97EFFC37937DF871B9189577838686490A37247BCECF5382B96CF234E64B731E6B83DBBF9CB9B089245FCAC8E8D9A36D2DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134B32946CCAB9BE7ACC5FCBFBA1A36405EC79D8846A5F8A522D190403BA57ED6D069935   More>>

Dear Sir,

Actually I'm Reading Msg from Socket Sent by C++ Program
(Server),It will send 2 msgs/sec.the msg format is like is

|1118|0074|01|0023 |1234 |MIG|11FTR01|0eT0000023000318|000050|R|sampl eT msg Ref 0023000318;#STEPSD45C4F1E13A23CFB2DEAC4CBB6F4DD42E44BAB47F8944CF8F77ACB035F4D0652F2695D0A995240124CFEB539773551648F3A0118620DD293BD8EA139AB3BCE2ACDC4454B437E7C57618F97AB7E177C99B03D1D37D9119A16D8428025FEE1E4C93BEC9AE4275E86A22594CB739FFAFDB97EFFC37937DF871B9189577838686490A37247BCECF5382B96CF234E64B731E6B83DBBF9CB9B089245FCAC8E8D9A36D2DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134B32946CCAB9BE7ACC5FCBFBA1A36405EC79D8846A5F8A522D190403BA57ED6D069935ED00284D1F695BC02F9503DC696DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB61345CD256C8777695CC57AE9826FC72E9B6524348C53A2205AC3D8C6D6F66416CC28B302458B8E25C5754E695AD7D7E116979EC131B40904FCEDF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134DF415E0336AB6134E2E858FCED961E53#| ]


ie., Starting with pipe(|)Total Msg Length ends with |.Based on the total msg length only I'm receiving
msg.Actually the program is thread based.The Problem is
that some time the receiving msg length is wrong format(it is the part of the msg)

my ErrorLog showing like this.

[ 09:57:34 ] => [ Message is Wrong Format(MSG LEN)=0336A ]

Suggest me what may be the problem whether socket or
receiving side(java program),I'm receiving msg without blocking.Receiving part code as follows,





if(soc != null)

{

BufferedInputStream recdMsg = new BufferedInputStream(soc.getInputStream());

stringbuffer = new StringBuffer();

byte abyte0[] = new byte[5];

int j = 0;

int i;

if((i = recdMsg.read(abyte0, 0, 5)) != -1)

{

String chkNum = new String(abyte0);

stringbuffer.append(new String(abyte0));

int k = MsgExtractor.isNumber((new Stringabyte0)).substring(1));

if(k != 1)

{

j = Integer.parseInt((new String(abyte0)).substring(1));

j -= 5;

}

else if (k == 1 || !chkNum.startsWith("|"))

{

sc.ErrorLog("Message is Wrong Format(MSG LEN)
="+chkNum, logcode, "A");
}


byte ch[]=new byte[j];

recdMsg.read(ch,0,j);

stringbuffer.append(new String(ch));

}//End of if((i = recdMsg.read(abyte0, 0, 5)) != -1)

}// End of if(naradasoc != null)

else

{

return;


}

naradamsg = stringbuffer.toString();




Plz help me.,
-Raja.

   <<Less
About | Sitemap | Contact