deliver of Serializable object by ServerSocketChannel
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   hemdat_cohen
Posted On:   Tuesday, July 30, 2002 09:02 AM

Hi everyone. I try to deliver an object from a client to the server by using the nio package. in the old good socket object I should do : ObjectInputStream in = null; try{ in = new ObjectInputStream(incomeSocket.getInputStream()); .... everything work . but , I try to do it with the nio package , and to stop using all this threads. my new code : ObjectInputStream in = null; try{ in = new ObjectInputStream(callback.getChannel().socket().getInputStream()); .... and (!) error : error : java.nio.channels.Illegal   More>>

Hi everyone.
I try to deliver an object from a client to the server by using the nio package.
in the old good socket object I should do :


ObjectInputStream in = null;

try{

in = new ObjectInputStream(incomeSocket.getInputStream());

....


everything work .

but , I try to do it with the nio package , and to stop using all this threads.

my new code :


ObjectInputStream in = null;

try{

in = new ObjectInputStream(callback.getChannel().socket().getInputStream());

....



and (!) error :

error : java.nio.channels.IllegalBlockingModeException


someone know why ???

U know I should do something with ByteArrayInputStream
but also with this I had problems :



try{

ByteBuffer byteBuffer = ByteBuffer.allocate( BUFSIZE );

int nbytes = callback.getChannel().read( byteBuffer );

byteBuffer.flip();

ByteArrayInputStream byteArrayInputStream = new
ByteArrayInputStream(byteBuffer.array());

in = new ObjectInputStream(byteArrayInputStream);

input = (String)in.readObject();

}

catch (Exception e){

System.out.println("Error : "+e);

}



and the error :

Error : java.io.StreamCorruptedException: invalid stream header

on the line of new ObjectInputStream.

maybe it have connection to the buffer size ??

maybe something else ????

thanks U all.

Hemdat

   <<Less
About | Sitemap | Contact