harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jimmy, Jing Lv" <firep...@gmail.com>
Subject Re: [classlib][nio][question] Peek on DatagramChannel.receive(ByteBuffer) ?
Date Thu, 06 Jul 2006 03:24:20 GMT
Andrew Zhang wrote:
> Hello everybody,
> 
> When I reviewed o.a.h.nio.internal.DatagramChannelImpl, I found following
> FIXME:
> " // // FIXME donot peek at time,see if can improve
>            // DatagramPacket peekPack = new DatagramPacket(new byte[1], 1);
>            // synchronized (dataLock) {
>            // networkSystem.receiveDatagram(fd, peekPack, peekPack.getData
> (),
>            // peekPack.getOffset(), peekPack.getLength(),
>            // isBlocking() ? 0 : DEFAULT_TIMEOUT, true);
>            // }
>            // if (null == peekPack.getAddress()) {
>            // // if no new packet peeked
>            // return null;
>            // } "
> I feel a little puzzled by this FIXME. After writing several tests, I don't
> think peek is necessary.
> 
> Could anyone tell me whether peek operation makes any sense here?
> 

It seems the code tries to peek if any datagram packages arrived and 
returns immediately if none. I guess it also wants to see where does the 
package come from and do some security check as many network programs 
do(currently it does the check after recieve). However, DatagramChannel 
will discards all packages that fail in security check, so IMHO peek 
here is not necessary. I agree that these lines can be removed.


> Thanks!
> 
> Best regards,
> 


-- 

Best Regards!

Jimmy, Jing Lv
China Software Development Lab, IBM

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Mime
View raw message