• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NIO Channel -Object Transfer

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i was trying this test code given below, for transfer of objects thru NIO Channels..
Everything working fine but at the point when i try to create a ObjectOutputStream ...using the SocketChannel ... i get an error saying ::->
java.nio.channels.IllegalBlockingModeException .
i really dont understand why this happens ...
is there any thing wrong that i am doin?.....
Please Help Me ....

Thanks A Lot
regards
Merwin
---------------------------------------------------------------------
HERE is the CODE
---------------------------------------------------------------------

import java.io.*;
import java.net.*;
import java.nio.*;
import java.nio.channels.*;
import java.util.*;

public class DateServerNIO {
static final int port = 1313;

void process() throws IOException {

ServerSocketChannel serverChannel = ServerSocketChannel.open();
serverChannel.socket().bind(new InetSocketAddress(port));
System.out.println("Socket bound");
Selector mux = Selector.open();
serverChannel.configureBlocking(false);
serverChannel.register(mux, SelectionKey.OP_ACCEPT);
System.out.println("Channel registered");

while (mux.select() > 0) {
Iterator keyIt = mux.selectedKeys().iterator();
while (keyIt.hasNext()) {
SelectionKey key = (SelectionKey) keyIt.next();
if (key.isAcceptable()) {
ServerSocketChannel server =(ServerSocketChannel) key.channel();
SocketChannel channel = server.accept();
if (channel != null) {
// channel.configureBlocking(false);
// channel.register (mux, SelectionKey.OP_READ);
ObjectOutputStream dateOut =new OutputStream
(Channels.newOutputStream (channel));
//Here is where the problem comes
dateOut.writeObject(new Date());
}
}
keyIt.remove();
}
}
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please do not post the same topic in multiple forums. We all read multiple forums so you are not increasing your audience and the community may duplicate effort answering your three posts.
 
merwin pinto
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am really sorry about the duplicate posts......
i assure you it will not happen again
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic