java: indicate reads writes illusory patience socketchannel around object(in|out)putstreams?


i combined an objectinputsteam objectoutputstream patience socketchannel am perplexing review concurrently. formula something this:



socketchannel = socketchannel.open(destnode);
objectoutputstream = new objectoutputstream(channels.newoutputstream(socketchannel));
objectinputstream = new objectinputstream(channels.newinputstream(socketchannel));

thread replythread = new thread("sendrunnable-replythread") {
@override
open vacant run() {
try {
byte respond = objectinputstream.readbyte();//(a)
//..process reply
} locate (throwable e) {
logger.warn("problem reading accept reply.", e);
}
}
};
replythread.start();

objectoutputstream.writeobject(someobject);//(b)
//..more writing


problem during line (b) blocks until review during line (a) completes (blocks vigilant returned selectablechannel#blockinglock() ). nonetheless app explanation dictates review finish until writes complete, have an effective deadlock.



socketchannel javadocs contend indicate reads writes supported.



i means such problem i attempted unchanging dale solution:



socket dale = new socket();
socket.connect(destnode);
final outputstream outputstream = socket.getoutputstream();
objectoutputstream = new objectoutputstream(outputstream);
objectinputstream = new objectinputstream(socket.getinputstream());


however, following i can't take advantage opening advantages filechannel#transferto(...)



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members