tcl.lang.channel
Class ServerSocketChannel

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

public class ServerSocketChannel
extends AbstractSocketChannel

The ServerSocketChannel class implements a channel object for ServerSocket connections, created using the socket -server 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
ServerSocketChannel(Interp interp, String localAddr, int port, TclObject callback)
          Creates a new ServerSocketChannel object with the given options.
 
Method Summary
 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.
 void seek(Interp interp, long offset, int mode)
          Override to provide specific errors for server socket.
 
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, 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

ServerSocketChannel

public ServerSocketChannel(Interp interp,
                           String localAddr,
                           int port,
                           TclObject callback)
                    throws TclException
Creates a new ServerSocketChannel object with the given options. Creates an underlying ServerSocket object, and a thread to handle connections to the socket.

Parameters:
interp - the current interpreter
localAddr - the IP address to bind to, or an empty string
port - the port to bind to, or 0 for any port
callback - the Tcl script specified by 'server -socket'
Throws:
TclException
Method Detail

seek

public void seek(Interp interp,
                 long offset,
                 int mode)
          throws IOException,
                 TclException
Override to provide specific errors for server socket.

Overrides:
seek in class Channel
Parameters:
interp - currrent interpreter.
offset - The number of bytes to move the file pointer.
mode - where to begin incrementing the file pointer; beginning, current, end.
Throws:
IOException
TclException - if channel does not support seek

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.