Open GoogleCodeExporter opened 9 years ago
p.s. version 2.1.0
Original comment by Nikolai.Ivanoff@gmail.com
on 5 Mar 2010 at 10:24
if (commandLength > 16) {
int len = commandLength - 16;
int totalReaded = 16;
synchronized (in) {
while(totalReaded<len){
totalReaded += in.read(b, totalReaded,len-totalReaded);
}
}
}
May be this code withh help us in performing this task. This loop will make
sure that
the required number of bytes are read if the stream is available. Just make
sure that
if the client socket is closed, or if end-of-stream is reached, the read()
method
throws IOException.
Original comment by hbkricha...@gmail.com
on 19 Apr 2010 at 3:37
better:
if (commandLength > 16) {
int len = commandLength - 16;
int totalReaded = 16;
synchronized (in) {
while(totalReaded<len){
int readed = in.read(b, totalReaded, len-totalReaded);
if (readed < 0) {
throw new IOException("socket closed");
}
totalReaded += readed;
}
}
}
Original comment by Nikolai.Ivanoff@gmail.com
on 23 Apr 2010 at 8:41
The Suggested algorithms results the Time Out Exception.For example hence len =
8,so
len-totalReaded will be negative
So the algorithm should be as follows
if (commandLength > 16) {
int len = commandLength - 16;
int totalReaded = 16;
synchronized (in) {
while(len != 0){
int readed = in.read(b, totalReaded, len);
if (readed < 0) {
throw new IOException(
"Unexpected length of byte readed. Expecting " + len
+ " but only read " + totalReaded);
}
len -= readed;
totalReaded += readed;
}
}
}
Original comment by dominicu...@gmail.com
on 24 Jun 2010 at 11:16
Sorry for my mistake.
while(totalReaded<commandLength){
totalReaded += in.read(b, totalReaded,commandLength-totalReaded);
.....
}
Original comment by hbkricha...@gmail.com
on 2 Jul 2010 at 8:51
I've tried the fix from dominicu... It seems to work quite robustly. I've
confirmed with tcpdumps that several reassembled pdus were sent. These with the
orginal code would cause IOExceptions (a little harsh). Now with this fix they
are processed quite happily.
Is there any reason why this isn't apart of the DefaultPDUReader?
Regardless, the code allows for using a custom PDUReader quite easily. Maybe
the addition of a SafePDUReader is in order if there is no desire to see this
functionality in the DefaultPDUReader?
thanks, matt pinner
Original comment by mpin...@gmail.com
on 2 Mar 2011 at 3:11
Attachments:
How to read SMPP PDU and show?
Please hepl me.
Original comment by bulk24sm...@gmail.com
on 27 May 2014 at 12:28
Original issue reported on code.google.com by
Nikolai.Ivanoff@gmail.com
on 4 Mar 2010 at 5:25