I am trying to implement a simple client/server app using a DatagramChannel to pass ByteBuffers. The client seems to connect okay and the number of bytes returned from the write method is correct; however, the server side never seems to receive anything
Server side:
DatagramChannel inchannel;
DatagramSocket ds;
CLIENT_ADDRESS = 5000;
public void runServer() {
inChannel = DatagramChannel.open();
ds = inChannel.socket();
ds.bind(inAddress);
inChannel.connect(new InetSocketAddress("localhost", CLIENT_ADDRESS);
ByteBuffer inputBuffer = ByteBuffer.allocate(512); //plenty big enough
at this point print statements indicate that the channel is open and connected
while(true) {
try {
if (inChannel.isConnected()) { //it is
inputBuffer.clear(); //prep for reading
SocketAddress sock = inChannel.receive(inputBuffer);
inputBuffer.flip();
while (inputBuffer.hasRemaining() ) {
System.out.println(inputBuffer.get() + " ");
}
}
}
catch
etc.
I never see anything. Know I'm missing something pretty fundamental but can't understand what it is!!