KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > nio > channels > SocketChannel

java.nio.channels
Class SocketChannel

java.lang.Object
  extended by java.nio.channels.spi.AbstractInterruptibleChannel
      extended by java.nio.channels.SelectableChannel
          extended by java.nio.channels.spi.AbstractSelectableChannel
              extended by java.nio.channels.SocketChannel
All Implemented Interfaces:
Closeable, ByteChannel, Channel, GatheringByteChannel, InterruptibleChannel, ReadableByteChannel, ScatteringByteChannel, WritableByteChannel
See Also:
Top Examples, Source Code, AsynchronousCloseException, ClosedChannelException, shutdownOutput, shutdownInput, isConnectionPending, finishConnect, isConnected, connect, NotYetConnectedException, open, SocketImpl, socket

public abstract boolean connect(SocketAddress remote)
                         throws IOException
See Also:
SecurityException, UnsupportedAddressTypeException, UnresolvedAddressException, ClosedByInterruptException, AsynchronousCloseException, ClosedChannelException, ConnectionPendingException, AlreadyConnectedException, checkConnect, Socket, finishConnect
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract boolean finishConnect()
                               throws IOException
See Also:
ClosedByInterruptException, AsynchronousCloseException, ClosedChannelException, NoConnectionPendingException, connect
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract boolean isConnected()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract boolean isConnectionPending()
See Also:
finishConnect
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static SocketChannel open()
                          throws IOException
See Also:
SelectorProvider, openSocketChannel
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[78]non-blocking IO
By Anonymous on 2003/12/19 13:15:32  Rate
ByteBuffer buffer = ByteBuffer.allocate  ( 1024 ) ; 
 SocketChannel socketChannel = SocketChannel.open (  ) ; 
 socketChannel.configureBlocking  ( false ) ; 
  
  
 ... 
  
  
 while  ( true )   {  
    ... 
    if  ( socketChannel.read  ( buffer )  != 0 )   {  
       processInput  ( buffer ) ; 
     }  
 ... 
  } 


public static SocketChannel open(SocketAddress remote)
                          throws IOException
See Also:
SecurityException, UnsupportedAddressTypeException, UnresolvedAddressException, ClosedByInterruptException, AsynchronousCloseException, connect, open()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract int read(ByteBuffer dst)
                  throws IOException
See Also:
ClosedByInterruptException, AsynchronousCloseException, ClosedChannelException, NotYetConnectedException, ReadableByteChannel
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final long read(ByteBuffer[] dsts)
                throws IOException
See Also:
ClosedByInterruptException, AsynchronousCloseException, ClosedChannelException, NotYetConnectedException, ScatteringByteChannel
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract long read(ByteBuffer[] dsts,
                          int offset,
                          int length)
                   throws IOException
See Also:
ClosedByInterruptException, AsynchronousCloseException, ClosedChannelException, NotYetConnectedException, ScatteringByteChannel
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract Socket socket()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected SocketChannel(SelectorProvider provider)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final int validOps()
See Also:
SelectableChannel, SelectionKey.OP_WRITE, SelectionKey.OP_READ, SelectionKey.OP_CONNECT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract int write(ByteBuffer src)
                   throws IOException
See Also:
ClosedByInterruptException, AsynchronousCloseException, ClosedChannelException, NotYetConnectedException, WritableByteChannel
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1763]Write to a SocketChannel
By Anonymous on 2006/05/31 11:06:19  Rate
while  (  bb.hasRemaining (  )   )   {  
    int len = socketChannel.write ( bb ) ; 
    if  ( len  <  0 )  {  
       throw new EOFException (  ) ; 
     }   
  }  


public final long write(ByteBuffer[] srcs)
                 throws IOException
See Also:
ClosedByInterruptException, AsynchronousCloseException, ClosedChannelException, NotYetConnectedException, GatheringByteChannel
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract long write(ByteBuffer[] srcs,
                           int offset,
                           int length)
                    throws IOException
See Also:
ClosedByInterruptException, AsynchronousCloseException, ClosedChannelException, NotYetConnectedException, GatheringByteChannel
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags