1828330 Members
4773 Online
109976 Solutions
New Discussion

JAVA 141 on OpenVMS

 
Dieter Rossbach
Regular Advisor

JAVA 141 on OpenVMS

The following java code runs fine under W2K, but generates an exception unter VMS 7.3-1, latest Patch level, JAVA 141 ...

import java.util.Iterator;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;

public class select {

public static void main(String[] args) {
try {
int timeout = 1000;

Selector selector = Selector.open();
ServerSocketChannel ssc = ServerSocketChannel.open();
ssc.configureBlocking(false);
InetSocketAddress isa = new InetSocketAddress( 4711);
ssc.socket().bind( isa, 1);
ssc.register( selector, SelectionKey.OP_ACCEPT);

selector.select(timeout); // <----- Generates Exception

Iterator it = selector.selectedKeys().iterator();

while (it.hasNext()) {
it.remove();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

java.io.IOException: socket operation on non-socket
at sun.nio.ch.PollArrayWrapper.poll0(Native Method)
at sun.nio.ch.PollArrayWrapper.poll(PollArrayWrapper.java)
at sun.nio.ch.PollSelectorImpl.doSelect(PollSelectorImpl.java)
at sun.nio.ch.SelectorImpl.select(SelectorImpl.java)
at select.main(select.java)


Any ideas?

Dieter
2 REPLIES 2
Martin P.J. Zinser
Honored Contributor

Re: JAVA 141 on OpenVMS

Just an (educated?) guess: From the output you
quote it looks like this Java function tries to
do "native" i.e. C based, I/O using the poll
function. Since poll is not implemented in the
C RTL this might be the causing trouble.
Craig A Berry
Honored Contributor

Re: JAVA 141 on OpenVMS

Actually poll() is in the latest CRTL ECO, though they left it out of the header on the first go-round so it's hard to know you have it.

The problem is more likely to be related to the fact that select() only works on sockets on VMS. It's possible that the flags in the selector object are not getting set up right so that it gets recognized as a socket. If it's possible to do the equivalent of the S_ISSOCK test in C, that may at least tell you if this is what's happening. Sorry not to have more Java-specific info.