tcl.lang.channel
Class SocketChannel

java.lang.Object
  extended by tcl.lang.channel.Channel
      extended by tcl.lang.channel.AbstractSocketChannel
          extended by tcl.lang.channel.SocketChannel

public class SocketChannel
extends AbstractSocketChannel

The SocketChannel class implements a channel object for Socket connections, created using the socket command.


Field Summary
 
Fields inherited from class tcl.lang.channel.Channel
blocking, buffering, bufferSize, encoding, eofInputFilter, eofOutputFilter, eolInputFilter, eolOutputFilter, finalInputStream, finalReader, firstOutputStream, firstWriter, inputBuffer, inputEofChar, inputTranslation, markableInputStream, mode, nonBlockingOutputStream, outputBuffer, outputEofChar, outputTranslation, rawInputStream, rawOutputStream, READ_OWNERSHIP, refCount, unicodeDecoder, unicodeEncoder, WRITE_OWNERSHIP
 
Constructor Summary
SocketChannel(Interp interp, int mode, String localAddr, int localPort, boolean async, String address, int port)
          Constructor - creates a new SocketChannel object with the given options.
SocketChannel(Interp interp, Socket s)
          Constructor for making SocketChannel objects from connections made to a ServerSocket.
 
Method Summary
protected  void connectSocket(InetAddress addr, int port, InetAddress localAddress, int localPort)
          Create the 'sock' field and connect the Socket
 TclObject getError(Interp interp)
          This option gets the current error status of the given socket.
protected  InputStream getInputStream()
          This method should be overridden in the subclass to provide a channel specific InputStream object.
protected  OutputStream getOutputStream()
          This method should be overridden in the subclass to provide a channel specific OutputStream object.
 
Methods inherited from class tcl.lang.channel.AbstractSocketChannel
getPeerName, getSockName, setOutputTranslation
 
Methods inherited from class tcl.lang.channel.Channel
checkRead, checkWrite, close, eof, flush, getBlocking, getBuffering, getBufferSize, getChanName, getEncoding, getInputEofChar, getInputTranslation, getOutputEofChar, getOutputTranslation, initInput, initOutput, isBlocked, isClosed, isReadOnly, isReadWrite, isWriteOnly, read, seek, setBlocking, setBuffering, setBufferSize, setEncoding, setInputEofChar, setInputTranslation, setOutputEofChar, setOwnership, setOwnership, tell, waitForOwnership, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketChannel

public SocketChannel(Interp interp,
                     int mode,
                     String localAddr,
                     int localPort,
                     boolean async,
                     String address,
                     int port)
              throws IOException,
                     TclException
Constructor - creates a new SocketChannel object with the given options.

Parameters:
interp - the current interpreter
localAddr - localAddress to use, or empty string if default is to be used
localPort - local port to use, or 0 if any port is to be used
async - true if socket should be connected asynchronously
address - IP address or hostname to connect to
port - port to connect to
Throws:
IOException
TclException

SocketChannel

public SocketChannel(Interp interp,
                     Socket s)
              throws IOException,
                     TclException
Constructor for making SocketChannel objects from connections made to a ServerSocket.

Parameters:
interp - the current interpreter
s - A connected socket from which to create a channel
Throws:
IOException
TclException
Method Detail

connectSocket

protected void connectSocket(InetAddress addr,
                             int port,
                             InetAddress localAddress,
                             int localPort)
Create the 'sock' field and connect the Socket

Parameters:
addr - Address to connect to
port - Port to connect to
localAddress - Local address to bind, or null for default
localPort - Local port to bind to, or 0 for any port
Throws:
IOException

getInputStream

protected InputStream getInputStream()
                              throws IOException
Description copied from class: Channel
This method should be overridden in the subclass to provide a channel specific InputStream object.

Specified by:
getInputStream in class Channel
Throws:
IOException

getOutputStream

protected OutputStream getOutputStream()
                                throws IOException
Description copied from class: Channel
This method should be overridden in the subclass to provide a channel specific OutputStream object.

Specified by:
getOutputStream in class Channel
Throws:
IOException

getError

public TclObject getError(Interp interp)
                   throws TclException
Description copied from class: AbstractSocketChannel
This option gets the current error status of the given socket. This is useful when you need to determine if an asynchronous connect operation succeeded. If there was an error, the error message is returned. If there was no error, an empty string is returned.

Specified by:
getError in class AbstractSocketChannel
Parameters:
interp - current interpreter, for errors
Returns:
Error message or empty string if no error
Throws:
TclException


Copyright © 2015. All rights reserved.