buffer.clear();
while (true) {
InetSocketAddress sa;
sa = (InetSocketAddress) channel.receive (buffer);
if (sa != null) {
return (sa);
}
long sleepTime = giveup - System.currentTimeMillis();
if (sleepTime <= 0) {
return (null);
}
System.out.println ("Selecting for " + (sleepTime / 1000) + " seconds");
selector.select (sleepTime);
}