I'm trying to send and receive messages over sockets using non-blocking sockets. I found the following example (http://www.exampledepot.com/egs/java...tSocket.html):

{code}
// Creates a non-blocking socket channel for the specified host name and port.
// connect() is called on the new channel before it is returned.
public static SocketChannel createSocketChannel(String hostName, int port) throws IOException {
// Create a non-blocking socket channel
SocketChannel sChannel = SocketChannel.open();
sChannel.configureBlocking(false);

// Send a connection request to the server; this method is non-blocking
sChannel.connect(new InetSocketAddress(hostName, port));
return sChannel;
}

// Create a non-blocking socket and check for connections
try {
// Create a non-blocking socket channel on port 80
SocketChannel sChannel = createSocketChannel("hostname.com", 80);

// Before the socket is usable, the connection must be completed
// by calling finishConnect(), which is non-blocking
while (!sChannel.finishConnect()) {
// Do something else
}
// Socket channel is now ready to use
} catch (IOException e) {
}
{code}

...but I get the compile-time error "InetSocketAddress cannot be resolved to a type" on this line:

{code}
sChannel.connect(new InetSocketAddress(hostName, port));
{code}

...but when trying to incorporate it into my existing code, I get:

"The method getInputStream() is undefined for the type SocketChannel"
-and:
"The method getOutputStream() is undefined for the type SocketChannel"

...here (last two lines):

{code}
try {
// Create a non-blocking socket channel on port 80
sDispatchChannel = RT_TCP_JCP_TDS_OO_State_SortSim_Utils.createSocket Channel(sIPAddr,
Integer.parseInt(tfDispatchPort.getText()));
inDispatchFile = new DataInputStream(
sDispatchChannel.getInputStream());
outDispatchFile = sDispatchChannel.getOutputStream();
...
{code}

Does anybody know how I can initialize a DataInputStream using a SocketChannel (as opposed to a Socket)? Or have I been drinking too much Congress Water ("you are what your drink")?