Network file transfer

Xiao Li xiao.k.li at googlemail.com
Tue Oct 11 22:43:04 EDT 2011


Hi,
  I have to jump out and say something.
  I knew about Netty since a couple of months ago and have implemented
success application to handle CLI
request, auto-packet-segmentation,  multi-level frame codec, RPC, in
distributed system.

  Netty is very neat to use, and here is the steps I adopted it (share it
before I ignored):
1. browse the user guide quickly
2. run a echo server example and make some modification to get hands-on
experience
3. read the user guide again, and make notes on it (via pdf editor such as
PDF-Xchange or just print it out)
4. write a telnet server, and start to learn the ideas of codec in netty
(need to understand Intercepting Filter pattern, which has introduction in
MSDN or Oracle)
5. read docs from http://docs.jboss.org/netty/3.2/api/index.html, and make
sure that I have understood following classes
ChannelPipeline,ChannelHandler, ChannelEvent,
 ChannelHandlerContext,ChannelBuffer)
6. The most important part, when I have question. I write it down (in
Evernote), and try best firstly to answer it by own after research. Unlike
Microsoft stuff, netty's source code is exposed to myself,so it is easy to
trace down logic flow in code via breakpoints. and watchers.
7. I have not asked question to community now, but will ask if I need to
discuss about design or don't have clue about how to progress in debugging.
Just bare in mind, as Netty is opensource, ask self before asking community:
is there any further debugging I can do?

Good Luck
-Xiao





On Wed, Oct 12, 2011 at 3:26 AM, metalstorm <metalheadstorm at gmail.com>wrote:

> ok ive tried:
>
> 'ChanneBuffers.wrappedBuffers(byte[])'
>
> I get corrupted data on the client end.
>
> using a dynamic buffer
>
> private final ChannelBuffer buf = new DynamicChannelBuffer(1024 * 8);
>
>                        FileInputStream in = new FileInputStream(myFile);
>
>
>                         byte[] buffer = new byte[1024 * 8];
>
>                        int read = 0;
>                        int totalRead = 0;
>                        System.out.println("file size: " + myFile.length());
>                        while ((read = in.read(buffer, 0, buffer.length)) >
> 0)
>                        {
>                                buf.writeBytes(buffer, 0, read);
>                                //
> ch.write(ChannelBuffers.wrappedBuffer(buffer, 0, read));
>                                ch.write(buf);
>                                totalRead += read;
>                                System.out.println("read: " + read);
>                                System.out.println("totalread: " +
> totalRead);
>
>                        }
>
> which seems to give me double the file on client end, so if the file
> contained 1234 i would get 12341234
>
> im using Normans code with
> FileOutputStream out = new FileOutputStream("fileToSend.txt", true);
> I find it has to be set to true otherwise the file is only 1 buffer size
> big
>
> Sample debugging data:
>
> Server:
>
> got file: fileToSend.txt
> file size: 8206
> read: 8192
> totalread: 8192
> read: 14
> totalread: 8206
>
> Client (line.length):
>
> has array: 1024
> has array: 2048
> has array: 2048
> has array: 3072
> has array: 4096
> has array: 4124
>
> to save your maths, = 16412 = (8206 x 2)
>
> I don't see how it receiving 2x the data when on 1 x is sent?
>
>
>
>
>
> --
> View this message in context:
> http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Network-file-transfer-tp6875434p6882322.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20111012/7d70f8f6/attachment.html 


More information about the netty-users mailing list