Class OncRpcTcpServerTransport

    • Field Detail

      • socket

        private java.net.ServerSocket socket
        TCP socket used for stream-based communication with ONC/RPC clients.
      • bufferSize

        private int bufferSize
        Size of send/receive buffers to use when encoding/decoding XDR data.
      • transmissionTimeout

        protected int transmissionTimeout
        Timeout during the phase where data is received within calls, or data is sent within replies.
      • characterEncoding

        private java.lang.String characterEncoding
        Encoding to use when deserializing strings or null if the system's default encoding should be used.
    • Constructor Detail

      • OncRpcTcpServerTransport

        public OncRpcTcpServerTransport​(OncRpcDispatchable dispatcher,
                                        int port,
                                        int program,
                                        int version,
                                        int bufferSize)
                                 throws OncRpcException,
                                        java.io.IOException
        Create a new instance of a OncRpcTcpServerTransport which encapsulates TCP/IP-based XDR streams of an ONC/RPC server. This particular server transport only waits for incoming connection requests and then creates OncRpcTcpConnectionServerTransport server transports to handle individual connections. This constructor is a convenience constructor for those transports handling only a single ONC/RPC program and version number.
        Parameters:
        dispatcher - Reference to interface of an object capable of dispatching (handling) ONC/RPC calls.
        port - Number of port where the server will wait for incoming calls.
        program - Number of ONC/RPC program handled by this server transport.
        version - Version number of ONC/RPC program handled.
        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.
        Throws:
        OncRpcException
        java.io.IOException
      • OncRpcTcpServerTransport

        public OncRpcTcpServerTransport​(OncRpcDispatchable dispatcher,
                                        int port,
                                        OncRpcServerTransportRegistrationInfo[] info,
                                        int bufferSize)
                                 throws OncRpcException,
                                        java.io.IOException
        Create a new instance of a OncRpcTcpServerTransport which encapsulates TCP/IP-based XDR streams of an ONC/RPC server. This particular server transport only waits for incoming connection requests and then creates OncRpcTcpConnectionServerTransport server transports to handle individual connections.
        Parameters:
        dispatcher - Reference to interface of an object capable of dispatching (handling) ONC/RPC calls.
        port - Number of port where the server will wait for incoming calls.
        info - Array of program and version number tuples of the ONC/RPC programs and versions handled by this transport.
        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.
        Throws:
        OncRpcException
        java.io.IOException
      • OncRpcTcpServerTransport

        public OncRpcTcpServerTransport​(OncRpcDispatchable dispatcher,
                                        java.net.InetAddress bindAddr,
                                        int port,
                                        OncRpcServerTransportRegistrationInfo[] info,
                                        int bufferSize)
                                 throws OncRpcException,
                                        java.io.IOException
        Create a new instance of a OncRpcTcpServerTransport which encapsulates TCP/IP-based XDR streams of an ONC/RPC server. This particular server transport only waits for incoming connection requests and then creates OncRpcTcpConnectionServerTransport server transports to handle individual connections.
        Parameters:
        dispatcher - Reference to interface of an object capable of dispatching (handling) ONC/RPC calls.
        bindAddr - The local Internet Address the server will bind to.
        port - Number of port where the server will wait for incoming calls.
        info - Array of program and version number tuples of the ONC/RPC programs and versions handled by this transport.
        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.
        Throws:
        OncRpcException
        java.io.IOException
    • Method Detail

      • close

        public void close()
        Close the server transport and free any resources associated with it.

        Note that the server transport is not deregistered. 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.

        Calling this method on a OncRpcTcpServerTransport results in the listening TCP network socket immediately being closed. In addition, all server transports handling the individual TCP/IP connections will also be closed. The handler threads will therefore either terminate directly or when they try to sent back replies.

        Specified by:
        close in class OncRpcServerTransport
      • removeTransport

        protected void removeTransport​(OncRpcTcpConnectionServerTransport transport)
        Removes a TCP/IP server transport from the list of currently open transports.
        Parameters:
        transport - Server transport to remove from the list of currently open transports for this listening transport.
      • register

        public void register()
                      throws OncRpcException
        Register the TCP/IP port where this server transport waits for incoming requests with the ONC/RPC portmapper.
        Specified by:
        register in class OncRpcServerTransport
        Throws:
        OncRpcException - if the portmapper could not be contacted successfully of if the portmapper rejected port registration(s).
      • retrieveCall

        public void retrieveCall​(XdrAble call)
                          throws OncRpcException,
                                 java.io.IOException
        Do not call.
        Specified by:
        retrieveCall in class OncRpcServerTransport
        Throws:
        java.lang.Error - because this method must not be called for a listening server transport.
        OncRpcException - if an ONC/RPC exception occurs, like the data could not be successfully deserialized.
        java.io.IOException - if an I/O exception occurs, like transmission failures over the network, etc.
      • getXdrDecodingStream

        protected XdrDecodingStream getXdrDecodingStream()
        Do not call.
        Specified by:
        getXdrDecodingStream in class OncRpcServerTransport
        Returns:
        Reference to decoding XDR stream.
        Throws:
        java.lang.Error - because this method must not be called for a listening server transport.
      • endDecoding

        protected void endDecoding()
                            throws OncRpcException,
                                   java.io.IOException
        Do not call.
        Specified by:
        endDecoding in class OncRpcServerTransport
        Throws:
        java.lang.Error - because this method must not be called for a listening server transport.
        OncRpcException - if an ONC/RPC exception occurs, like the data could not be successfully deserialized.
        java.io.IOException - if an I/O exception occurs, like transmission failures over the network, etc.
      • getXdrEncodingStream

        protected XdrEncodingStream getXdrEncodingStream()
        Do not call.
        Specified by:
        getXdrEncodingStream in class OncRpcServerTransport
        Returns:
        Reference to enecoding XDR stream.
        Throws:
        java.lang.Error - because this method must not be called for a listening server transport.
      • beginEncoding

        protected void beginEncoding​(OncRpcCallInformation callInfo,
                                     OncRpcServerReplyMessage state)
                              throws OncRpcException,
                                     java.io.IOException
        Do not call.
        Specified by:
        beginEncoding in class OncRpcServerTransport
        Parameters:
        callInfo - Information about ONC/RPC call for which we are about to send back the reply.
        state - ONC/RPC reply header indicating success or failure.
        Throws:
        java.lang.Error - because this method must not be called for a listening server transport.
        OncRpcException - if an ONC/RPC exception occurs, like the data could not be successfully serialized.
        java.io.IOException - if an I/O exception occurs, like transmission
      • endEncoding

        protected void endEncoding()
                            throws OncRpcException,
                                   java.io.IOException
        Do not call.
        Specified by:
        endEncoding in class OncRpcServerTransport
        Throws:
        java.lang.Error - because this method must not be called for a listening server transport.
        OncRpcException - if an ONC/RPC exception occurs, like the data could not be successfully serialized.
        java.io.IOException - if an I/O exception occurs, like transmission failures over the network, etc.
      • reply

        protected void reply​(OncRpcCallInformation callInfo,
                             OncRpcServerReplyMessage state,
                             XdrAble reply)
                      throws OncRpcException,
                             java.io.IOException
        Do not call.
        Specified by:
        reply in class OncRpcServerTransport
        Parameters:
        callInfo - information about the original call, which are necessary to send back the reply to the appropriate caller.
        state - ONC/RPC reply message header indicating success or failure and containing associated state information.
        reply - If not null, then this parameter references the reply to be serialized after the reply message header.
        Throws:
        java.lang.Error - because this method must not be called for a listening server transport.
        OncRpcException - if an ONC/RPC exception occurs, like the data could not be successfully serialized.
        java.io.IOException - if an I/O exception occurs, like transmission failures over the network, etc.
        See Also:
        OncRpcCallInformation, OncRpcDispatchable
      • listen

        public void listen()
        Creates a new thread and uses this thread to listen to incoming ONC/RPC requests, then dispatches them and finally sends back the appropriate reply messages. Control in the calling thread immediately returns after the handler thread has been created.

        For every incomming TCP/IP connection a handler thread is created to handle ONC/RPC calls on this particular connection.

        Specified by:
        listen in class OncRpcServerTransport
      • setTransmissionTimeout

        public void setTransmissionTimeout​(int milliseconds)
        Set the timeout used during transmission of data. If the flow of data when sending calls or receiving replies blocks longer than the given timeout, an exception is thrown. The timeout must be > 0.
        Parameters:
        milliseconds - Transmission timeout in milliseconds.
      • getTransmissionTimeout

        public int getTransmissionTimeout()
        Retrieve the current timeout used during transmission phases (call and reply phases).
        Returns:
        Current transmission timeout.
      • setCharacterEncoding

        public void setCharacterEncoding​(java.lang.String characterEncoding)
        Set the character encoding for (de-)serializing strings.
        Specified by:
        setCharacterEncoding in class OncRpcServerTransport
        Parameters:
        characterEncoding - the encoding to use for (de-)serializing strings. If null, the system's default encoding is to be used.
      • getCharacterEncoding

        public java.lang.String getCharacterEncoding()
        Get the character encoding for (de-)serializing strings.
        Specified by:
        getCharacterEncoding in class OncRpcServerTransport
        Returns:
        the encoding currently used for (de-)serializing strings. If null, then the system's default encoding is used.