1 7 8 package java.nio.channels; 9 10 import java.io.IOException ; 11 import java.net.DatagramSocket ; 12 import java.net.SocketAddress ; 13 import java.nio.ByteBuffer ; 14 import java.nio.channels.spi.*; 15 16 17 54 55 public abstract class DatagramChannel 56 extends AbstractSelectableChannel 57 implements ByteChannel , ScatteringByteChannel , GatheringByteChannel 58 { 59 60 63 protected DatagramChannel(SelectorProvider provider) { 64 super(provider); 65 } 66 67 81 public static DatagramChannel open() throws IOException { 82 return SelectorProvider.provider().openDatagramChannel(); 83 } 84 85 95 public final int validOps() { 96 return (SelectionKey.OP_READ 97 | SelectionKey.OP_WRITE); 98 } 99 100 101 103 111 public abstract DatagramSocket socket(); 112 113 119 public abstract boolean isConnected(); 120 121 168 public abstract DatagramChannel connect(SocketAddress remote) 169 throws IOException ; 170 171 190 public abstract DatagramChannel disconnect() throws IOException ; 191 192 251 public abstract SocketAddress receive(ByteBuffer dst) throws IOException ; 252 253 313 public abstract int send(ByteBuffer src, SocketAddress target) 314 throws IOException ; 315 316 317 319 332 public abstract int read(ByteBuffer dst) throws IOException ; 333 334 347 public abstract long read(ByteBuffer [] dsts, int offset, int length) 348 throws IOException ; 349 350 363 public final long read(ByteBuffer [] dsts) throws IOException { 364 return read(dsts, 0, dsts.length); 365 } 366 367 378 public abstract int write(ByteBuffer src) throws IOException ; 379 380 397 public abstract long write(ByteBuffer [] srcs, int offset, int length) 398 throws IOException ; 399 400 417 public final long write(ByteBuffer [] srcs) throws IOException { 418 return write(srcs, 0, srcs.length); 419 } 420 421 } 422 | Popular Tags |