/// <summary>
 /// Create a new instance of a <code>OncRpcTcpSConnectionerverTransport</code>
 /// which encapsulates TCP/IP-based XDR streams of an ONC/RPC server.
 /// </summary>
 /// <remarks>
 /// Create a new instance of a <code>OncRpcTcpSConnectionerverTransport</code>
 /// which encapsulates TCP/IP-based XDR streams of an ONC/RPC server. This
 /// particular server transport handles individual ONC/RPC connections over
 /// TCP/IP.
 /// </remarks>
 /// <param name="dispatcher">
 /// Reference to interface of an object capable of
 /// dispatching (handling) ONC/RPC calls.
 /// </param>
 /// <param name="socket">TCP/IP-based socket of new connection.</param>
 /// <param name="info">
 /// Array of program and version number tuples of the ONC/RPC
 /// programs and versions handled by this transport.
 /// </param>
 /// <param name="bufferSize">
 /// Size of buffer used when receiving and sending
 /// chunks of XDR fragments over TCP/IP. The fragments built up to
 /// form ONC/RPC call and reply messages.
 /// </param>
 /// <param name="parent">Parent server transport which created us.</param>
 /// <param name="transmissionTimeout">Inherited transmission timeout.</param>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 /// <exception cref="System.IO.IOException"></exception>
 public OncRpcTcpConnectionServerTransport(org.acplt.oncrpc.server.OncRpcDispatchable
                                           dispatcher, Socket socket, org.acplt.oncrpc.server.OncRpcServerTransportRegistrationInfo
                                           [] info, int bufferSize, org.acplt.oncrpc.server.OncRpcTcpServerTransport parent
                                           , int transmissionTimeout) : base(dispatcher, 0, info)
 {
     this.parent = parent;
     this.transmissionTimeout = transmissionTimeout;
     //
     // Make sure the buffer is large enough and resize system buffers
     // accordingly, if possible.
     //
     if (bufferSize < 1024)
     {
         bufferSize = 1024;
     }
     this.socket = socket;
     this.port   = ((IPEndPoint)socket.RemoteEndPoint).Port;
     if (socket.SendBufferSize < bufferSize)
     {
         socket.SendBufferSize = bufferSize;
     }
     if (socket.ReceiveBufferSize < bufferSize)
     {
         socket.ReceiveBufferSize = bufferSize;
     }
     //
     // Create the necessary encoding and decoding streams, so we can
     // communicate at all.
     //
     sendingXdr   = new org.acplt.oncrpc.XdrTcpEncodingStream(socket, bufferSize);
     receivingXdr = new org.acplt.oncrpc.XdrTcpDecodingStream(socket, bufferSize);
     //
     // Inherit the character encoding setting from the listening
     // transport (parent transport).
     //
     setCharacterEncoding(parent.getCharacterEncoding());
 }
 /// <summary>Close the server transport and free any resources associated with it.</summary>
 /// <remarks>
 /// Close the server transport and free any resources associated with it.
 /// <p>Note that the server transport is <b>not deregistered</b>. You'll
 /// have to do it manually if you need to do so. The reason for this
 /// behaviour is, that the portmapper removes all entries regardless of
 /// the protocol (TCP/IP or UDP/IP) for a given ONC/RPC program number
 /// and version.
 /// <p>Calling this method on a <code>OncRpcTcpServerTransport</code>
 /// results in the listening TCP network socket immediately being closed.
 /// The handler thread will therefore either terminate directly or when
 /// it tries to sent back replies.
 /// </remarks>
 public override void Close()
 {
     if (socket != null)
     {
         //
         // Since there is a non-zero chance of getting race conditions,
         // we now first set the socket instance member to null, before
         // we close the corresponding socket. This avoids null-pointer
         // exceptions in the method which waits for new requests: it is
         // possible that this method is awakened because the socket has
         // been closed before we could set the socket instance member to
         // null. Many thanks to Michael Smith for tracking down this one.
         //
         Socket deadSocket = socket;
         socket = null;
         try
         {
             deadSocket.Close();
         }
         catch (System.IO.IOException)
         {
         }
     }
     if (sendingXdr != null)
     {
         org.acplt.oncrpc.XdrEncodingStream deadXdrStream = sendingXdr;
         sendingXdr = null;
         try
         {
             deadXdrStream.Close();
         }
         catch (System.IO.IOException)
         {
         }
         catch (org.acplt.oncrpc.OncRpcException)
         {
         }
     }
     if (receivingXdr != null)
     {
         org.acplt.oncrpc.XdrDecodingStream deadXdrStream = receivingXdr;
         receivingXdr = null;
         try
         {
             deadXdrStream.Close();
         }
         catch (System.IO.IOException)
         {
         }
         catch (org.acplt.oncrpc.OncRpcException)
         {
         }
     }
     if (parent != null)
     {
         parent.removeTransport(this);
         parent = null;
     }
 }
        /// <summary>
        /// Create a new instance of a <code>OncRpcTcpSConnectionerverTransport</code>
        /// which encapsulates TCP/IP-based XDR streams of an ONC/RPC server.
        /// </summary>
        /// <remarks>
        /// Create a new instance of a <code>OncRpcTcpSConnectionerverTransport</code>
        /// which encapsulates TCP/IP-based XDR streams of an ONC/RPC server. This
        /// particular server transport handles individual ONC/RPC connections over
        /// TCP/IP.
        /// </remarks>
        /// <param name="dispatcher">
        /// Reference to interface of an object capable of
        /// dispatching (handling) ONC/RPC calls.
        /// </param>
        /// <param name="socket">TCP/IP-based socket of new connection.</param>
        /// <param name="info">
        /// Array of program and version number tuples of the ONC/RPC
        /// programs and versions handled by this transport.
        /// </param>
        /// <param name="bufferSize">
        /// Size of buffer used when receiving and sending
        /// chunks of XDR fragments over TCP/IP. The fragments built up to
        /// form ONC/RPC call and reply messages.
        /// </param>
        /// <param name="parent">Parent server transport which created us.</param>
        /// <param name="transmissionTimeout">Inherited transmission timeout.</param>
        /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        public OncRpcTcpConnectionServerTransport(org.acplt.oncrpc.server.OncRpcDispatchable
			 dispatcher, Socket socket, org.acplt.oncrpc.server.OncRpcServerTransportRegistrationInfo
			[] info, int bufferSize, org.acplt.oncrpc.server.OncRpcTcpServerTransport parent
			, int transmissionTimeout)
            : base(dispatcher, 0, info)
        {
            this.parent = parent;
            this.transmissionTimeout = transmissionTimeout;
            //
            // Make sure the buffer is large enough and resize system buffers
            // accordingly, if possible.
            //
            if (bufferSize < 1024)
            {
                bufferSize = 1024;
            }
            this.socket = socket;
            this.port = ((IPEndPoint)socket.RemoteEndPoint).Port;
            if (socket.SendBufferSize < bufferSize)
            {
                socket.SendBufferSize = bufferSize;
            }
            if (socket.ReceiveBufferSize < bufferSize)
            {
                socket.ReceiveBufferSize = bufferSize;
            }
            //
            // Create the necessary encoding and decoding streams, so we can
            // communicate at all.
            //
            sendingXdr = new org.acplt.oncrpc.XdrTcpEncodingStream(socket, bufferSize);
            receivingXdr = new org.acplt.oncrpc.XdrTcpDecodingStream(socket, bufferSize);
            //
            // Inherit the character encoding setting from the listening
            // transport (parent transport).
            //
            setCharacterEncoding(parent.getCharacterEncoding());
        }
 /// <summary>
 /// Create a new instance of a <code>OncRpcTcpSConnectionerverTransport</code>
 /// which encapsulates TCP/IP-based XDR streams of an ONC/RPC server.
 /// </summary>
 /// <remarks>
 /// Create a new instance of a <code>OncRpcTcpSConnectionerverTransport</code>
 /// which encapsulates TCP/IP-based XDR streams of an ONC/RPC server. This
 /// particular server transport handles individual ONC/RPC connections over
 /// TCP/IP. This constructor is a convenience constructor for those transports
 /// handling only a single ONC/RPC program and version number.
 /// </remarks>
 /// <param name="dispatcher">
 /// Reference to interface of an object capable of
 /// dispatching (handling) ONC/RPC calls.
 /// </param>
 /// <param name="socket">TCP/IP-based socket of new connection.</param>
 /// <param name="program">
 /// Number of ONC/RPC program handled by this server
 /// transport.
 /// </param>
 /// <param name="version">Version number of ONC/RPC program handled.</param>
 /// <param name="bufferSize">
 /// Size of buffer used when receiving and sending
 /// chunks of XDR fragments over TCP/IP. The fragments built up to
 /// form ONC/RPC call and reply messages.
 /// </param>
 /// <param name="parent">Parent server transport which created us.</param>
 /// <param name="transmissionTimeout">Inherited transmission timeout.</param>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 /// <exception cref="System.IO.IOException"></exception>
 public OncRpcTcpConnectionServerTransport(org.acplt.oncrpc.server.OncRpcDispatchable
                                           dispatcher, Socket socket, int program, int version, int bufferSize, org.acplt.oncrpc.server.OncRpcTcpServerTransport
                                           parent, int transmissionTimeout) : this(dispatcher, socket, new org.acplt.oncrpc.server.OncRpcServerTransportRegistrationInfo
                                                                                   [] { new org.acplt.oncrpc.server.OncRpcServerTransportRegistrationInfo(program,
                                                                                                                                                          version) }, bufferSize, parent, transmissionTimeout)
 {
 }