Replace this:
MappedByteBuffer buffer = channel.map(MapMode.READ_ONLY, 0,1024);

to:
MappedByteBuffer buffer = channel.map(MapMode.READ_ONLY, readed,1024);

2008/6/27 kalees waran <[EMAIL PROTECTED]>:

> #
> # An unexpected error has been detected by Java Runtime Environment:
> #
> # java.lang.OutOfMemoryError: requested 655360 bytes for GrET in
> C:\BUILD_AREA\jdk6_06\hotspot\src\share\vm\utilities\growableArray.cpp. Out
> of swap space?
> #
> #  Internal Error (allocation.inline.hpp:42), pid=2240, tid=3476
> #  Error: GrET in
> C:\BUILD_AREA\jdk6_06\hotspot\src\share\vm\utilities\growableArray.cpp
> #
> # Java VM: Java HotSpot(TM) Client VM (10.0-b22 mixed mode, sharing
> windows-x86)
> # An error report file with more information is saved as:
> # C:\Documents and Settings\kaleeswaran\workspace\mina1\hs_err_pid2240.log
> #
> # If you would like to submit a bug report, please visit:
> #   http://java.sun.com/webapps/bugreport/crash.jsp
> #
>
> i got this error when i write 15 mb file in buffer....
>
>
> please suggest me suitable one ..actually this is my requirement
>
> 1.i want to sent big wav file and sent text file......
>
> 2.i want to decode and encode voicefile and text file and compression also
>
>
> please suggest me i am new guy for this mina framework.......
>
>
>
>
>
>
>
>
>
> On Fri, Jun 27, 2008 at 4:04 PM, Viktor Balázs <[EMAIL PROTECTED]>
> wrote:
>
> > I think this code is working only on localhost, becuase you send the
> > serialized File object and not the content of file. The serialized File
> > object contain the path of file, so the length is correct. You must write
> > the content of file to IoSession. You can use FileChannel to load files
> to
> > ByteBuffer (the code is an example only, I don't tested this):
> >
> > *            File file = new File("any file name");
> > >             FileInputStream fis = new FileInputStream(file);
> > >             FileChannel channel = fis.getChannel();
> > >             long readed = 0;
> > >             while(readed != file.length()){
> > >                 ByteBuffer buffer = channel.map(MapMode.READ_ONLY, 0,
> > > 1024);
> > >                 buffer.rewind();
> > >                 readed += buffer.limit();
> > >                 session.write(buffer);
> > >             }    *
> > >
> >
> >
> > 2008/6/27 kalees waran <[EMAIL PROTECTED]>:
> >
> > > On Fri, Jun 27, 2008 at 1:41 PM, Viktor Balázs <
> [EMAIL PROTECTED]>
> > > wrote:
> > >
> > > > Do you want to write byte content of file or a "new File(...)"
> object?
> > :)
> > > > Or
> > > > what is the "file object"? Do you send an example?
> > > >
> > > > 2008/6/27 kalees waran <[EMAIL PROTECTED]>:
> > > >
> > > > > i want to send and download bulk file using mina. i am trying to
> > write
> > > > file
> > > > > object in the session.write(fileobject).however i got client side
> in
> > > null
> > > > > pointer exception..which codec i want to use to write object in
> mina
> > > > >
> > > >
> > > public class Client {
> > >  public static void main(String arg[]){
> > >
> > >    SocketConnector connector = new SocketConnector();
> > >    connector.setWorkerTimeout(1);
> > >    SocketConnectorConfig cfg = new SocketConnectorConfig();
> > >    cfg.getFilterChain().addLast( "logger", new LoggingFilter() );
> > >    cfg.getFilterChain().addLast( "codec",new ProtocolCodecFilter( new
> > > ObjectSerializationEncoder(),new ObjectSerializationDecoder() ));
> > >    cfg.getFilterChain().addLast("threadPool", new
> > > ExecutorFilter(Executors.newCachedThreadPool()));
> > >    IoSession session;
> > >    ConnectFuture future = connector.connect(new InetSocketAddress("
> > > 192.168.10.197", 9123),
> > >        new ClientHandler(), cfg);
> > >        future.join();
> > >
> > >            session = future.getSession();
> > >
> > >            session.getCloseFuture().join();
> > >
> > > session.close();
> > >
> > >
> > > }
> > >
> > > > //handler
> > > >
> > > public void sessionCreated(IoSession session) throws Exception{
> > >
> > >        File f=new File("E:/Downloads/voicesys.exe");
> > >        System.out.println(f.length());
> > >        session.write(f);
> > >        session.write("ksdkosfsd");
> > >
> > >
> > >    }
> > >
> > > ////////////////////server
> > >
> > > public void messageReceived(IoSession session, Object msg) throws
> > Exception
> > > {
> > >
> > >        Object o=msg;
> > >        File f=(File)o;
> > >        System.out.println(f.length());
> > >        System.out.println(msg);
> > >        session.write("hi");
> > >        session.close();
> > >    }
> > >
> > > i have write this code for sending and receiving file
> > > now its working fine...i want to know this is the  right coding to send
> > the
> > > file to server bz my work is more challaging work.bz there is the
> chance
> > > 20000 client to sent and download file at a time..even i dont have any
> > > clear
> > > idea about thread pooling in mina.i wnt to send to voice file the size
> > may
> > > big...
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > >
> > > >
> > > >
> > > > --
> > > > Balázs Viktor
> > > > Amkai Kft. (1188 Budapest, Szövet u. 9.)
> > > >
> > > > Email: [EMAIL PROTECTED]
> > > > Jabber: [EMAIL PROTECTED]
> > > > MSN: [EMAIL PROTECTED]
> > > > Telefon: +36-30/6755532
> > > >
> > >
> >
> >
> >
> > --
> > Balázs Viktor
> > Amkai Kft. (1188 Budapest, Szövet u. 9.)
> >
> > Email: [EMAIL PROTECTED]
> > Jabber: [EMAIL PROTECTED]
> > MSN: [EMAIL PROTECTED]
> > Telefon: +36-30/6755532
> >
>



-- 
Balázs Viktor
Amkai Kft. (1188 Budapest, Szövet u. 9.)

Email: [EMAIL PROTECTED]
Jabber: [EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]
Telefon: +36-30/6755532

Reply via email to